ATM question

#include
#include
#include<math.h>
using namespace std;
bool check(int x)
{
if(x%5==0)
return true;
else
return false;
}

float withdraw(float balance, int amt)
{
    return (balance-amt-.50);
}
     
int main()
{   int amount;
    float balance;
   
    cin>>amount>>balance;
  cout.setf(ios::fixed);
    
    
    if(amount>0 && amount <= 2000 && balance>0 && balance<=2000)
    {
       if(balance>=amount)
       {
         if(check(amount))
         {
            
            cout<<setprecision(2)<<withdraw(balance,amount);
         }
         else
         cout<<setprecision(2)<< balance;
        }
         else
         cout<<setprecision(2)<<balance;
     }
        
    
    return 0;
}

The checking condition should be balance>=amount+0.5

1 Like

thanaks bro…got correct

//