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

×

Help me in ATM

#include<iostream>
 #include<iomanip>
using namespace std;
 int main(){
int with;
float bal;
cout<<"input";
cin>>with>>bal;
if(with>=0 && bal>=0.00 && with<=2000 && bal<=2000.00  && bal!=with && bal>=with && ( (with+ 0.50)<bal ) && (with%5==0) )
  {


        bal= bal- with-0.50;
       cout<<bal;
         }
         else
          cout<<bal;
return 0;

}

i don't know what is wrong with code. i have tried everything but it still says wrong answer

asked 09 Aug, 22:12

angad_789's gravatar image

0★angad_789
1
accept rate: 0%

converted to question 09 Aug, 22:33

vijju123's gravatar image

4★vijju123 ♦
11.3k1316


cout<<"input"

Dont print such superfluous statements. Its a machine checking if your output is an exact match of expected one or not. It will print WA on encountering such a case.

(with+ 0.50)<bal

Is bank balance of 0 not allowed in the question? I think a balance of 0 is allowed :/

link

answered 09 Aug, 22:35

vijju123's gravatar image

4★vijju123 ♦
11.3k1316
accept rate: 18%

Exact input/output format should be maintained. First, omit line cout<<"input" Second, the output should be given corrected up to 2 decimal places. In C++, you can use setprecision function in the header file <iomanip>. Check it out here :- http://www.cplusplus.com/reference/iomanip/setprecision/

Just change your line cou<<bal to cout<<fixed<<setprecision(2)<<bal and it'll get accepted :-)

link

answered 10 Aug, 22:19

markus__'s gravatar image

5★markus__
934
accept rate: 0%

toggle preview
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:

×1,979
×843

question asked: 09 Aug, 22:12

question was seen: 206 times

last updated: 10 Aug, 22:19