ATM easy problem. whats wrong here? c++

using namespace std;

int main(){
int withdraw;
float cash;

cin >> withdraw >> cash;

if(withdraw > cash)

    cout << setprecision(2)<<showpoint << fixed << cash  << endl;
else if ((withdraw +.50)<= cash)

    if (withdraw % 5 == 0){
    cout << setprecision(2) << showpoint << fixed << (cash-0.50) - withdraw << endl;}
    cout << setprecision(2) << showpoint << fixed << cash << endl;

return 0;

btw, those constraints given, am i supposed to place it in a if statement to check it? or the test cases here will automatically not exceed within the given constraints?

First check it there is enough balance including that 0.5 when subtracted and now check if it is a multiple of 5. Here a corresponds to your withdraw and b corresponds to your cash

if (b-0.5>=a && a%5==0)


else if(b-0.5>a && a%5!=0)



1 Like

Please tell me if you have any doubts regarding this condition.

thanks, this actually worked for me :slight_smile:
anyway, can you answer my last question about constraints?

by the way can you please accept this answer! So that i can close this question. Left to my answer there is a Vote-Up and Vote Down Symbol. Below that there is a tick mark. That is the way to accept it! :slight_smile: thanks :slight_smile: