## p156ex14: Bills Bills Bills

A gas company has a monthly billing rate based on the total gas consumption by its customers. The charge varies according to the meter reading (m3). The rate structure is as following:

 Total Consumption Total Charge For the first 10m3 or less \$6.59 (minimum bill) For the next 20m3 23.73 cents/m3 For the next 55m3 22.71 cents/m3 For the next 85m3 21.78 cents/m3 For the next 170m3 or above 20.85 cents/m3

Note: There are situations where the final reading may be less than the initial reading. For example, the initial reading might be 9980 while the final reading is 0015 indicating a consumption during the month of 35m3 because the meter has 'rolled over'.

### Input

For each customer, the program should read an account number 0 ≤ A ≤ 99999 and two meter readings 0 ≤ M1, M2 < 10000. M1 represents the reading at the beginning of the month while M2 represents the reading at the beginning of the next month. The first line of input will be the account number. The second line of input will be M1 followed by a space then M2. The input will be terminated if and only if a negative account number is entered.

### Output

For each customer, your program should re-output the customer's account number and then on a new line output the final charge in dollars rounded off to two decimal places.

34567
0000 0005
12345
0000 0015
-1

### Sample Output

Account_#:_34567
Bill:_6.59
Account_#:_12345
Bill:_7.78

The '_' are used to represent spaces. Your program should output spaces instead of the underscores.

Point Value: 7
Time Limit: 2.00s
Memory Limit: 16M
Added: Oct 27, 2008

Languages Allowed:
C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3

## Comments (Search)

<
1
2
>

• (0/1)
WHATS WRONG WITH MY PYTHON 2 CODE

• (0/0)
check you formating and rounding, and you ranges

• (0/0)
remeber, you have to round

• (0/3)
(Python 3)

• (0/1)
Your code is simply incorrect. There isn't really much to say...

• (0/1)
Does my code have a rounding error
or another type?

• (0/1)
Your code has multiple issues, including rounding.

• (0/1)

• (0/1)
You are only given a 20 byte preview of your WA outputs. It means that the rest of the output is hidden.

• (0/1)
Could you tell me what is wrong? It seems to work when I test.

• (1/1)
Reread the problem statement.

• (0/1)
Can you tell me what my program is doing incorrectly? I keep getting the 2nd test case wrong.

• (0/1)
Read the entire problem statement - you missed a part.

• (1/1)
is the cost of the gas from 10-30 m3 23.73 cents/m3 or is it from 10-20 23.73 cents/m3. ie:
10-30 23.73 cents/m3
30-85 22.71 cents/m3
...

or
10-20 23.73 cents/m3
20-55 22.71 cents/m3
...

• (0/1)
Actually, nevermind, I'm really not sure. From what I first thought, and what the sample shows, it's actually the new price for the next 20m3 on top of the previous prices. ie if the reading was 15m3, like the second example in the sample, it's 5 * 23.73 + 659 (the rate for the first \$10) cents.

Not sure though, could require clarification.

• (0/1)
Yeah, that last thing you said is correct.

• (0/1)
Yeah, that's what I thought at first. However, looking again and answering this question, the "Total Charge" heading in the table was a bit confusing.

• (3/4)
Input: "For each customer, the program should read an account number 0 ≤ A ≤ 99999 and two meter readings 0 ≤ M1, M2 < 10000. M1 represents the reading at the beginning of the month while M2 represents the reading at the beginning of the next month. The first line of input will be the account number. The second line of input will be M1 followed by a space then M2. The input will be terminated if and only if a negative account number is entered." Appears as if the Input information is restating the same thing twice. Perhaps this could be edited.

• (1/10)
Is this affecting your ability to solve this problem?

• (1/2)
I believe that is a perfectly reasonable comment, John. Unlike you, he is making an attempt to be an useful member of society.

And more on topic, I don't see how it is repeating the same thing twice, Howard.

• (0/1)
"For each customer, the program should read an account number 0 ≤ A ≤ 99999 and two meter readings 0 ≤ M1, M2 < 10000. M1 represents the reading at the beginning of the month while M2 represents the reading at the beginning of the next month."
It then reiterates the same thing, only in a more technical way: "The first line of input will be the account number. The second line of input will be M1 followed by a space then M2. The input will be terminated if and only if a negative account number is entered." Appears as if the Input information is restating the same thing twice. Perhaps this could be edited."

• (0/1)
why me get wrong

• (0/1)
1. You're not outputting the account number.
2. Your cost calculation is wrong - the values given in the problem are PER m^3.

• (0/1)
oh didn't see that
thx
i do not get the "rolled over" part

• (1/2)
Arrgh!! It's so hard to see the spaces in the output!!!
Is there a way to make spaces easier to see?

• (1/1)
Account#
Account #
Looks pretty clear to me, but I guess I'll change the font.

• (0/3)
Do you output a space between the colon and the the corresponding number??

1) "Account #: 34567"
2) "Account #:34567"

• (1/2)
As Hanson mentioned before. It seems quite clear in the sample output.

Account #: 34567
Bill: 6.59
Account #: 12345
Bill: 7.78

• (2/5)
Is the first test case missing a '-1'? My program at most only does 160 loop executions per test case. There's no way I could have gotten a TLE if the test case is valid...is there?

• (0/1)
Where does it say it has to be a -1?
It could be any negative number...

• (0/4)
Heh...Heh...