ATM need help in solution

#include
using namespace std ;
int main() { int n ;
float bal ;
cin >> n >> bal ;
if ( n+0.05 > bal )
cout << bal ;
else if ( n%5!=0 )
cout << bal ;
else ( n%5==0 && bal>n )
cout << bal-n-0.05 ;
return 0;
}

you have got a few error here

  1. bank charges are 0.5 not 0.05
  2. in the last else statement you should add if also ie. it should be … else if( n%5==0 && bal>n ) …
  3. don’t know if this is the problem but to be on safe side do use set precision

ps. i have not run the code but if the problem persists do attach link to solution i will look up into it

The problem with your code is…

  1. You have to subtract 0.5 not 0.05.
  2. In last condition you need to add elseif condition not just else;;
  3. elseif(n%5== 0&& bal>n)
    cout << balance-n-.5;
  4. You also need to print only two decimal digits. You are not considering this factor which may lead you to wrong answer.

Hope This Helps.