using namespace std;
class ATM
{
private:
float accBalance; //Account Balance
float bankCharge; // Amount Charged by the bank for each succesful Transcation
public:
ATM(float accBalance = 1000, float bankCharge = 0.50)
{
this->accBalance = accBalance;
this->bankCharge = bankCharge;
}
void Transaction(float); // Function to calculate the Transaction
float getAccBalance() //Getter function for accessing the accBalance
{
return accBalance;
}
};
void ATM::Transaction(float amount = 0) // Transaction function definition
{
if(accBalance >= 5.50 && (fmod(amount,5) == 0) && amount<= accBalance + bankCharge)
{
accBalance -= amount;
}
}
int main()
{
float amount;
ATM account(1500);
cout<<"\n Welcome to your account POOJA!!!\n\nEnter the amount you want to Withdraw!!!";
cin>>amount;
cout<<"\n\nInput : \n"<<amount<<" "<<setprecision(2)<<fixed<<account.getAccBalance();
account.Transaction(amount);
cout<<"\nOutput : \n"<<account.getAccBalance();
return 0;
}
cout<<"\n Welcome to your account POOJA!!!\n\nEnter the amount you want to Withdraw!!!";
Statements like these are why you are getting WA.
The online judge does checking in a way like, your output should be EXACTLY equal to expected output stored in file.
In output format, they clearly mentioned to ONLY output the balance, and no other statement. Printing any other statement, character, or anything else will give you a WA.
1 Like