 # ATM: Need help in solution

can any one tell me what is wrong with my solution for The ATM problem.

``````/* Program to solve ATM problem on codechef
Author: Monjyoti Das
*/

#include<stdio.h>
int main(){

float bal;
int withdraw_amt;

printf("Input:(amount to withdraw & balance):");
(void)scanf("%d %f",&withdraw_amt, &bal);

if((float)withdraw_amt >= bal) {
printf("\nInsufficient Funds.\nOutput: %.2f\n",bal);
return 0;
}
if(withdraw_amt % 5 == 0) {
bal = bal-(float)0.50-withdraw_amt;
printf("\nOutput:\n %.2f\n",bal);
}
else {
printf("\nIncorrect Withdrawl Amount(not multiple of 5)\n Output:\n %.2f", bal);
}
return 0;
}``````

Please don’t print messages in printf()
Check the output format its consists only of digits.
Hope this works. If not let me know.

can some one tell me, what is the ATM problem? I’m new here.

1 Like

What cool_techie is trying to tell you is that you should only print the balance as a number, without any text. Check the question spec and example output.

#include
#include
using namespace std;
int main() {
float z, y,t;
int x;

``````//cin>>x>>y;
cin>>t;
while(t--){
cin>>z>>y;
x=z;
if(0<x&&x<=2000)
if(0<=y&&y<=2000)
if(x>y)
cout<<fixed<<setprecision(2)<<y;
else if(x%5!=0)
cout<<fixed<<setprecision(2)<<y;
else
cout<<fixed<<setprecision(2)<<y-x-0.50;
}

return 0;
``````

}

#include <stdio.h>
#include <stdlib.h>

int main()
{ int X;
float c,Y,z;
scanf("%d %f",&X,&Y);
c=Y-X-0.50;
if(Y<=2000&&Y>=0&&X>0&&X<=2000){
z=X;
if(X%5!=0||z+0.50>Y)
printf("%.2f",Y);
else
printf("%.2f",c);

}
else
return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main()
{ int X;
float c,Y,z;
scanf("%d %f",&X,&Y);
c=Y-X-0.50;
if(Y<=2000&&Y>=0&&X>0&&X<=2000){
z=X;
if(X%5!=0||z+0.50>Y)
printf("%.2f",Y);
else
printf("%.2f",c);

}
else
return 0;
}

there is no message in printf();
still it does not work
hope you can help me