# For my first question

Sir, I have a problem regarding my first question in my code chef…
For ATM problem,
Pooja would like to withdraw X \$US from an ATM. 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). For each successful withdrawal the bank charges 0.50 \$US. Calculate Pooja’s account balance after an attempted transaction.(For this question)

I have answered in the following way,

#include
using namespace std;
int main()
{
int x,y,r;
cout<<"Enter balance : ";
cin>>y;
cout<<"Enter the amount to be withdrawn : ";
cin>>x;
r=(x%5);
if((r==0)&&y>(x+0.50))
{
y=(y-x)+0.50;
cout<<"Remaining balacne = "<<y;
}
else
cout<<"Remaining balance = "<<y;
return 0;
}

You don’t have to output statements like->

cout<<"Enter balance : ";

cout<<"Enter the amount to be withdrawn : ";

…etc

Remove all such statements from your code.

Simply take the input values and output only the result.

1 Like

Sir, As you have suggested to remove all display statements… I have done that. But Still I’m getting a wrong answer…
#include
using namespace std;
int main()
{
int x,y;
cin>>y;
cin>>x;
if((x%5==0)&&y>(x+0.50))
{
y=(y-(x+0.50));
cout<<y;
}
else
cout<<y;
return 0;
}

@kalivarapu, you have to take the input in order as asked in the problm.
In the problem x is input first and then y…so you have to take x as first input and y as second but in your code you have taken y as first input and x as second.

Also, as given in the problem y is a real number so you have to take y as floating point number(either double or float).

Also, if you read the output line carefully,u have asked to print amount with 2 digits of precision… so you have to use precision while printing the output statement.

Hope it will help…

Thank you so much sir, It helped me a lot… Moreover, I got a correct answer… Thank you very much…

Click on tick button instead of saying thanks

@kalivarapu
Whoever give u a correct and proper answer just click on tick if it’s ur own question…

That’s how we say thanks on discuss codechef

@kalivarapu Go through this tutorial to understand how online judge works Online Programming.