#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
- bank charges are 0.5 not 0.05
- in the last else statement you should add if also ie. it should be … else if( n%5==0 && bal>n ) …
- 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…
- You have to subtract 0.5 not 0.05.
- In last condition you need to add elseif condition not just else;;
- elseif(n%5== 0&& bal>n)
cout << balance-n-.5; - 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.