CodeSolved

Solved Programming Questions & Exercises

Calculate the price of water and fines of the subscribers based on consumption

Practice Easy 2050/ Download 359 Views

Write a program that, based on the following rules, calculates the cost of the subscribers' water consumed and determines the relevant exemption or penalty.

In this program, the following should be considered:

  1. Subscribers with consumption of less than 21 cubic meters are exempt from paying water.
  2. Subscribers with consumption of between 21 and 41 cubic meters will be subject to a 5 % fine.
  3. Subscribers will be fined 10 % with consumption of more than 41 cubic meters.
  4. The amount per cubic meter of water consumed is 111 tomans.

The program must first calculate the price of the water consumed and then determine the amount of fines or exemptions based on the amount of subscribers consumption.

For example, if a subscriber consumes 30 cubic meters of water, the price of water consumed as follows:

بهای آب مصرفی = 30 * 111

Then, given that his consumption is between 21 and 41 cubic meters, a 5 % fine is calculated and added to the water price.

Finally, the program must produce the following output:

مبلغ بهای آب مصرفی: ...
مبلغ جریمه: ...

Please note that the program must be designed to receive water intake from the user and perform the calculations correctly.

9 Answers

def mohasebe():
    masraf=float(input('میزان مصرف اب (متر مکعب)'))

    gheymat=111

    mohasebe=masraf * gheymat

    jarime=0

    if masraf < 21:
        jarime = 0
        print(f'مبلغ بهای اب مصرفی: {mohasebe}تومان')
        print('مبلغ جریمه: معاف از پرداخت')

    elif 21 <= masraf <=41:
        jarime= mohasebe * 0.05
        print(f'مبلغ بهای اب مصرفی:{mohasebe} تومان')
        print(f'مبلغ جریمه:{jarime} تومان')

    else:
        jarime=mohasebe * 0.10
        print(f'مبلغ بهای اب مصرفی: {mohasebe} تومان')
        print(f'مبلغ جریمه: {jarime} تومان')
mohasebe()
using System;

class WaterBilling
{
    static void Main()
    {
        # Get input from the user
        Console.Write("Enter water consumption (cubic meters): ");
        double consumption = double.Parse(Console.ReadLine());

        # Price per cubic meter of water
        double pricePerCubicMeter = 111;

        # Calculate the cost of consuming water
        double waterCost = consumption * pricePerCubicMeter;
        double penalty = 0;

        # Determining the penalty or exemption
        if (consumption < 21)
        {
            penalty = 0;
        }
        else if (consumption >= 21 && consumption <= 41)
        {
            penalty = waterCost * 0.05;
        }
        else
        {
            penalty = waterCost * 0.10;
        }

        # The final calculation
        double totalCost = waterCost + penalty;

        # View results
        Console.WriteLine($"Water cost: {waterCost:F2} Toman");
        Console.WriteLine($"Penalty amount: {penalty:F2} Toman");
    }
}
Ai Download C#
a=float(input("a:"))
b=a*111
if a<21:
    print(0)
if 21<a<41:
    print(b)
    print(5/100*b)
if a>41:
    print(b)
    print (10/100*b)   
User 5632 Download Python
wateruse = float(input("enter your water useg:"))

waterprice = 111

pool_be_masouliaty = 0

pardakhty = wateruse * waterprice

if wateruse < 21 :
    pool_be_masouliaty = 0
    pardakhty = 0
elif 21 <= wateruse <= 41 :
    pool_be_masouliaty = pardakhty * 0.05
else :
    pool_be_masouliaty = pardakhty * 0.10


print(f"You most pay: {pardakhty}")
print(f"Your penalty is: {pool_be_masouliaty}")
# Get input from the user
consumption = float(input("مقدار مصرف آب (متر مکعب): "))

# Price per cubic meter of water
price_per_cubic_meter = 111

# Calculate the cost of consuming water
water_cost = consumption * price_per_cubic_meter
penalty = 0

# Determining the penalty or exemption
if consumption < 21:
    penalty = 0
elif 21 <= consumption <= 41:
    penalty = water_cost * 0.05
else:
    penalty = water_cost * 0.10

# The final calculation
total_cost = water_cost + penalty

# View results
print(f"مبلغ بهای آب مصرفی: {water_cost:.2f} تومان")
print(f"مبلغ جریمه: {penalty:.2f} تومان")
Ai Download Python
a =int(input("a: "))
if a< 21:
    price = 0
    print( " مبلغ  بهای اب مصرفی: " , price)
else:
    if 21 < a<41 :
        price = 111 * a
        g =  0.05 * price
        print("مبلغ بهای اب مصرفی: " , price)
        print("جریمه: " , g)
    else:
        if a > 41:
            price = 111 * a
            g = 0.1 * price
            print("مبلغ بهای اب مصرفی: " , price)
            print( "جریمه: "  , g)
User 5396 Download Python
value_water=float(input("enter the value water>>>"))
if value_water>=0 and value_water<=21:
    print("total amount for paying--->",value_water*111,"\nyou are exempt from paying the fine!")
elif value_water>21 and value_water<=41:
    print("amount for paying--->",value_water*111,"\nYou must pay the fine so amount for paying---->",(value_water*111)*0.05,"\nfainally total amount you must pay----->",(value_water*111)+((value_water*111)*0.05))
elif value_water>41:
     print("amount for paying--->",value_water*111,"\nYou must pay the fine so amount for paying---->",(value_water*111)*0.1,"\nfainally total amount you must pay----->",(value_water*111)+((value_water*111)*0.1))
Shina Download Python
l1=[]
l2=[]
w1=[]
w2=[]
m1=[]
m2=[]
while True:
    b=input("Please enter your subscriber name:\n")
    if b=="":
        break
    else:
        a=float(input("Please enter the amount of water consumed by this subscriber in cubic meters:\n"))
        if a<21:
            l1.append(b)
            l2.append(a)
            continue
        elif 21<=a<=41:
            w1.append(b)
            w2.append(a)
            continue
        elif 41<a:
            m1.append(b)
            m2.append(a)
            continue
print("Names of esteemed subscribers exempt from paying water consumption fees:")
for i,j in enumerate(l1):
    print(f"  Sir/Madam {i+1} . {j} :")
    print(f"   Amount of water consumed : {l2[i]} mm")
    print(f"   Amount of water consumption : Exempt from paying consumption fees ")
    print("   The amount of the fine : No penalty")
    print(f"   Total amount paid including fines : 0 ")
print("\n")
print("Names of subscribers subject to a 5% penalty :")
for i1,j1 in enumerate(w1):
    print(f"  Sir/Madam {i1+1} . {j1} :")
    print(f"   Amount of water consumed : {w2[i1]} mm")
    print(f"   Amount of water consumption : {(w2[i1])*111}")
    print(f"   The amount of the fine :{(((w2[i1])*111)*(5/100))} ")
    print(f"   Total amount paid including fines : {((w2[i1])*111)+(((w2[i1])*111)*(5/100))}")
print("\n")
print("Names of subscribers subject to a 10% penalty :")
for i2,j2 in enumerate(m1):
    print(f"  Sir/Madam {i2+1} . {j2} :")
    print(f"   Amount of water consumed : {m2[i2]} mm")
    print(f"   Amount of water consumption : {(m2[i2])*111}")
    print(f"   The amount of the fine : {(((m2[i2])*111)*(10/100))}")
    print(f"   Total amount paid including fines : {((m2[i2])*111)+(((m2[i2])*111)*(10/100))}")

Zaras Download Python
jarema = 0
mabla = 0
mmok = int ( input ('metr mokaab aib masraf karde ? : ') )
baha_iab_masrafe = (111 * mmok)
if mmok > 21:
    if mmok < 41:
        jarema = (baha_iab_masrafe/5)
        mabla = (baha_iab_masrafe + jarema)
if mmok >21:
    if mmok < 41:
        jarema = (baha_iab_masrafe/10)
        mabla = (baha_iab_masrafe + jarema)
if mmok > 21:
    jarema = 0
    mabla = (baha_iab_masrafe + jarema)
print ('مبلق پرداختی' )
print (mabla)
print ('مقدار جریمه : ')
print (jarema)

User 5553 Download Python

Submit answer

Submitting answers is currently unavailable.

×
×
Close