Can anyone help me to figure out the problem with my code? For some reason the online compiler says my answer to be wrong, but I don't see anything wrong with my program.... Help Please!!!

#include
#include
#include

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.

2 Likes
//