The problem to solve that requires a couple ‘if/else’ statements.1
2
3
4
5
6An electric company measures the amount of electricity its customer use in kilowatt hours (kwh) and charges them
according to the following schedule:
first 12 kwh or less $2.80
next 78 kwh 8 cents each kwh
excess above 90 kwh 6 cents each kwh
Note that the minimum bill is $2.80. Write a program to calculate a customers bill
This is first draft on how it should be worked out pseudo like.1
2
3
4
5
6FlatFee 12kwh < $2.80 //will always be charged this.
the NEXT 78kwh (12kwh+78kwh) = 90kwh 0.08 // the wording is to show that its less than 90
>90kwh 0.06 //the rest of the bill.
//if the used was 91kwh... this is the sum.
>> 91kwh = 2.80 + (1x0.08) + (1x0.06)
FlatFee + one instance of the <90 + one instances of the >90.
1 | int usage = 0; |