CodeSolved

Solved Programming Questions & Exercises

Calculate the discount

Practice Easy 114/ Download 2277 Views

We have a list of different items along with their discount percentage and we want to know how much the final price of each product is after considering the discount.

Write a program that gets the product price and the percentage of the discount, and prints the final price and discount value at the output.

Program must continue until the user has not entered 0


gheymat mahsool: 10000000
Darsad Takhfif: 20

gheymat nahaei = 8000000
Takhfif = 2000000

11 Answers

This answer is only visible to premium members
This answer is only visible to premium members
This answer is only visible to premium members
let msg = 'error'
alert(msg) 
This answer is only visible to premium members
This answer is only visible to premium members

This answer is only visible to premium members

Subscription is currently unavailable.
This answer is only visible to premium members
This answer is only visible to premium members
This answer is only visible to premium members
let msg = 'error'
alert(msg) 
This answer is only visible to premium members
This answer is only visible to premium members

This answer is only visible to premium members

Subscription is currently unavailable.
This answer is only visible to premium members
This answer is only visible to premium members
This answer is only visible to premium members
let msg = 'error'
alert(msg) 
This answer is only visible to premium members
This answer is only visible to premium members

This answer is only visible to premium members

Subscription is currently unavailable.
f=0
a=0
while 1:
   i =int(input('geymat jens chande:'))
   a+=i
   takhfif=20
   darsad=100
   b=i*takhfif/darsad
   f+=b
   if i ==0:
    break
print(int(f),' darsade takhfife shoma')
print(int(a-f),' geymate nahayie jens')
Maryam.n Download Python
while 1:
    gheymate_mahsoul = float(input("lotfan gheymate mahsoul ra vared konoid(toman): "))
    darsad_takhfif = float(input("lotfan darsade takhfif ra vared konoid:  % "))
    takhfif = gheymate_mahsoul * (darsad_takhfif / 100)
    gheymate_nahaee = gheymate_mahsoul - takhfif
    if gheymate_mahsoul == 0:
        break
    print("gheymate mahsoul = ", gheymate_mahsoul, "toman \n", "darsade takhfif = ", darsad_takhfif,"%")
    print("gheymate nahaee = ", gheymate_nahaee, "toman" , "\n", "takhfif = ", takhfif, "toman")
def D(a, b):
    return a - b
def C(u, g):
    w = u / 100 
    return w * g   
while True:
    t = float(input("gheymat :"))
    if t == 0:
        break
    v = float(input('darsad takhfif : '))
    if t == 0:
        break
    k = C(t, v)
    print("-------------------------------")
    print('gheimat akhar :',D(t, k))
    print('takhfif : ', k)
    print("-------------------------------")
price = 1
while price != 0:
    price = int(input("gheymat mahsool: "))
    off_percent = int(input("darsad takhfif: "))
    real_price = int(price * ((100 - off_percent) / 100))
    off_price = int(price * (off_percent / 100))
    print(f"gheymat nahaei = {real_price}")
    print(f"takhfif = {off_price}")
User 2109 Download Python
while input() != 0 :
     n = int( input("gheymat mahsool:   "))
     m = int( input("darsad takhfif:   "))
     gheymat_nahaei = ( n * m ) / 100
     darsad_takhfif = n - gheymat_nahaei
     print( "gheymat nahaei:  " , gheymat_nahaei)
     print( "darsad takhfif:  " , darsad_takhfif)

Arshia.a Download Python
class GMT:

    G = int(input("Enter Ghamat Mahsool: "))
    T = int(input("Enter takhfif: "))

    GT=(G*T) /100
    GBF=(G-GT)

    print("Ghamat kala ba menhay takhfif:", GBF)
    print("taghfif be toman: ", GT)
Amirali Download Python
def calculate_final_price(price, discount_percentage):
    """محاسبه قیمت نهایی و مقدار تخفیف."""
    discount_amount = price * (discount_percentage / 100)
    final_price = price - discount_amount
    return final_price, discount_amount

def main():
    while True:
        # Get product price
        price_input = input("لطفاً قیمت محصول را وارد کنید (برای خروج عدد 0 را وارد کنید): ")
        price = float(price_input)
        
        # Check to exit
        if price == 0:
            print("برنامه خاتمه یافت.")
            break
        
        # Receive a percentage of discount
        discount_percentage = float(input("لطفاً درصد تخفیف را وارد کنید: "))
        
        # Calculate the final price and the amount of discount
        final_price, discount_amount = calculate_final_price(price, discount_percentage)
        
        # View results
        print(f"\nقیمت نهایی = {final_price:.0f}")
        print(f"مقدار تخفیف = {discount_amount:.0f}\n")

if __name__ == "__main__":
    main()
Mma123 Download Python
<< Previous page 1 2 Next page >>

Submit answer

Submitting answers is currently unavailable.

Related content

Detection using AI
×
×
Close