In: Computer Science
Desktop test
If the consumption does not exceed 400 kWh, the cost
is $ 0.1 / kWh
(2) If consumption exceeds 400 kWh but does not exceed 800 kWh, the
first 400 kWh is charged at
$ 0.1 / kWh and excess at $ 0.2 / kWh
(3) Consumption exceeding 800 kWh is charged the same as (2) but in
addition the customer is fined
$ 100
(4) There is a basic charge of $ 20 that is charged independent of
customer consumption
(5) Customers who live in rural areas have a discount of 10% of the
total bill
(6) Commercial customers have an additional tax of 7% of the total
invoice
(7) For rural and commercial clients an additional tax of 4% (not
7%, nor the discount of
10%)
Your program must present to the customer the total to be paid in
the most detailed way possible, for example, for a
non-rural commercial client that consumed 1000kWh, the output
should be something like:
For your report, run the program for the cases shown below. Present
PrtScrs of the input and the
output, and its corresponding desktop tests.
(1) Non-rural, non-commercial, 200 kWh
(2) Rural, non-commercial, 10kWh
(3) Rural, non-commercial, 500 kWh
(4) Rural, commercial, 700 kWh
(5) Non-rural, commercial, 1200 kWh
(6) Non-rural, non-commercial 1200 kWh
(7) Rural, non-commercial 1200 kWh
Is Phyton
is Phyton
Hi,
please find the code below.
#Desktop test
units=int(input("Number of unit consumed in Kwh(kilo watt per hour:
"))
cityOrRural= input("Enter if its a rural area or
city:Rural/Non-rural ")
CommOrHousehold = input("Enter if its a commercial or household
purpose:commercial/Non-commercial")
#variable declaration
fixedcharge=20.00 # basic charges for everyone
discount=0.00
tax=0.00
TotalInvoicewithdiscount=0.00
TotalInvoicewithdiscountntax=0.00
if(units>0 and units<=400):
payAmount=units*0.1 # below 400 its 0.1 per KW
elif(units>400 and units<=800):
payAmount=(400*0.1)+(units-400)*0.2 #first 400 at 0.1 and remaining
at 0.2
elif(units>800):
payAmount=(400*0.1)+(units-400)*0.2+100 #same as before plus 100
fine
else:
payAmount=0;
TotalInvoice= payAmount+fixedcharge
print("\nElecticity bill pay without tax or dicount =%.2f: "
%TotalInvoice);
if(cityOrRural == "Rural" and CommOrHousehold ==
"Non-commercial"): # doscount applied only for rural non commercial
people
discount=10
if(CommOrHousehold == "commercial" and cityOrRural ==
"Non-rural"):
tax=7
if(CommOrHousehold == "commercial" and cityOrRural ==
"Rural"):
tax=4
if(discount>0.00):
TotalInvoicewithdiscount = TotalInvoice -
(TotalInvoice*(discount/100))
else:
TotalInvoicewithdiscount = TotalInvoice
if(tax>0.00):
TotalInvoicewithdiscountntax = TotalInvoicewithdiscount -
(TotalInvoicewithdiscount*(tax/100))
else:
TotalInvoicewithdiscountntax = TotalInvoicewithdiscount
print("No of units consumed:",units)
print("Rural or Non-Rural:",cityOrRural)
print("commercial or Non-commercial:",CommOrHousehold)
print("basic pay amount:",payAmount)
print("fixedcharges:",fixedcharge)
print("total invoice:",TotalInvoice)
print("discount:",discount)
print("Tax:",tax)
print("Amount after discount:",TotalInvoicewithdiscount)
print("Amount after tax:",TotalInvoicewithdiscountntax)
code snapshot:
Output:
Kindly upvote.
Thanks,
Amruth