You are not logged in. Please login at www.codechef.com to post your questions!

×

# Whats wrong with my ATM ?

 1 1 well, I have tested all the examples mentioned in the problem description(which work all right on my computer using gcc 4.8.2) but when I upload and hit submit, it says running and then suddenly WRONG ANSWER with a cross, not sure whats wrong with my code, you may see it below: #include int main(void) { int amount; float balance; scanf ("%i %f", &amount, &balance); float ans = balance; if (amount % 5 == 0 && amount < balance) { ans = balance - (amount + 0.50); } printf ("%.2f", ans); return 0; }  asked 09 Jul '14, 20:07 6★nibnalin 161●1●5●16 accept rate: 0% Try this case 20 20.1 (09 Jul '14, 20:26) gautam943★ Well, how do i correct the error in this ? (09 Jul '14, 20:35) nibnalin6★ Read the question again and check the if condition in your code. (09 Jul '14, 20:38) gautam943★

 1 You are checking for "amount < balance" Instead, you should check for: "amount + 0.5 < balance && amt%5==0" this is because the sum, along with the extra 0.50 is required to do the transaction. answered 09 Jul '14, 20:36 116●4●12 accept rate: 0%
 0 The amount 0.50 is also to be deducted from the balance. So, the condition amount < balance should be amount <= (balance-0.5) answered 09 Jul '14, 20:36 1.8k●4●9●32 accept rate: 14%
 toggle preview community wiki:
Preview

### Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×3,703
×1,470
×846
×538
×189

question asked: 09 Jul '14, 20:07

question was seen: 861 times

last updated: 09 Jul '14, 20:38