## p108ex7 - Cost

Given an integer N (0 ≤ N ≤ 100,000) representing the mass of a letter in grams, print out the cost in cents to mail the letter.

The first line of input will be the number of test cases T (1 ≤ T ≤ 100). The following T lines will contain N. Output the cost in cents to mail the letter.

The pricing is as follows :

0 ≤ N ≤ 30 costs 38 cents
30 < N ≤ 50 costs 55 cents
50 < N ≤ 100 costs 73 cents
if N > 100 then the base cost is 73 cents, plus 24 cents for every additional 50 grams or part thereof.

### Input

The first line of input will be the number of test cases T (1 ≤ T ≤ 100). The following T lines will contain N.

### Output

Output the cost in cents to mail the letter.

`2`
`5`
`101`

### Sample Output

`38`
`97`

Point Value: 3
Time Limit: 2.00s
Memory Limit: 16M

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

<
1
2
>

• (0/0)
What is wrong with my code? It works for all my test cases and its always a 7/11.

• (0/0)
my code will only garner a 1/11. How should I improve it?

• (0/2)
first, please read the question carefully next time, there are multiple cases, the first integer tells u how many cases in total, and the cases will follow. your program can only take one case, it should be able to take multiple

• (2/0)
I don't know what I'm doing wrong

• (2/0)
Being able to figure out what you're doing wrong is a more important skill than being able to figure out a solution in the first place.

Write out some test cases for yourself -- make up some possible inputs, then try to figure out what the output should be for that. Then, run your program with those inputs.

• (0/2)

• (1/0)
What should the extra charge be if a letter is exactly 50 grams more than the limit?

• (0/0)
I don't know

• (1/0)
 if N > 100 then the base cost is 73 cents, plus 24 cents for every additional 50 grams or part thereof.

• (0/0)
121

• (1/0)
Why 121?
50 grams or part thereof - 150 is 50 grams exactly. As such, only one additional charge is incurred... don't blindly trust your program; if you're asked a question intended to provoke thought as to why you got something wrong, it would make sense to pay it some attention...

• (0/1)

• (0/0)
what does part thereof mean?

• (0/0)
didnt brian just answer this question with one of your other posts?

• (0/0)
nvm

• (0/0)
"Part thereof" means a part of the thing just mentioned. So even if the thing weighs just one gram extra, it is still charged as a full fifty grams.

• (0/2)
xactly gaby how would you not now that?

• (1/0)
so mean

• (0/1)
gaby ur code for cost the else if n>100 thing is too long
there should be a simple formula for it...consisting of only two lines...its just the formula ur doing is wrong. think more of it...like instead of subtracting 100, something a BIT bigger...

• (0/0)
Why am i getting it wrong can someone check :S

• (0/0)
First rewrite your program so that it processes test cases one at a time, instead of reading in the entire input and then printing the entire output all in one shot.

• (0/0)
Does it want us to add the outputs and are there negative inputs.

I am writing this because my program works for the test cases but none of them are right when I submit.

• (0/0)
n2 := (24 * d) + 24;

• (0/0)
Your method of calculating is simply wrong.

• (0/0)
everything? or only the above 100 part?