×

# ATM problem

 0 PLEASE ANSWER IMMEDIATELY i am a new user and the problem i am trying to solve is ATM this is my programme #include int main () { int a, b; std::cin>>a>>b; if(a<=2000 && b<=2000 &&a>0 && b>=0){ if(a<=b){ if(a%5==0){ std::cout<<(b-(a+0.50)); } else std::cout<

 1 first of all your account balance should be a floating or double type value.since every time an amount of 0.50 $is to be charged by ATM therefore you should add if(a+0.500 && b>=0)as not asked by the program. answered 21 Nov '14, 15:20 171●3 accept rate: 15%  0 @mithunmuru Leaving the logic behind, the very first thing that you should learn is indenting your code. Not only the code looks clean but it helps you to see through your code for logical and syntactical error but also helps other people you may ask for help. Secondly you must understand that you don't have to check the conditions given on the test cases. Like the this piece of code in your program - if(a<=2000 && b<=2000 && a>0 && b>=0) is useless. You must think about your logic keeping in mind that the codechef judge will only give the given values as test cases and hence you don't have to check for such conditions and write statements like these - std::cout<<"invalid input" Now another thing to keep in mind while writing your program is output format. It is possible that your logic for a particular question is absolutely correct but the output format is wrong then no matter what you do you will get a wrong answer every time. These were some basic things you should keep in mind. Regarding the error in your code the condition that you applied in a and b is wrong. Try to run your code for different varieties of test cases and check what should be the condition on a and b. Think hard on this line form the question - "The cash machine will only accept the transaction if X is a multiple of 5, and Pooja's account balance has enough cash to perform the withdrawal transaction (including bank charges)". answered 19 Nov '14, 10:48 105●4●8●11 accept rate: 0%  0 use this code. i got my answer correct. include include using namespace std; int main() { float y; int x; cin>>x; cin>>y; if(x>=0&&x<=2000&&y>=0&&y<=2000) { if((x+0.50)  toggle preview community wiki: Preview ### Follow this question By Email: Once you sign in you will be able to subscribe for any updates here By RSS: Answers Answers and Comments Markdown Basics • *italic* or _italic_ • **bold** or __bold__ • link:[text](http://url.com/ "title") • 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:

×190

question asked: 19 Nov '14, 09:25

question was seen: 684 times

last updated: 21 Nov '14, 15:37