Question: How can I modify my code so that there is not a single blank line in the output, but each senetence must also begin on

How can I modify my code so that there is not a single blank line in the output, but each senetence must also begin on a different line:#include
#include
class PiggyBank
{
public:
//stores the balance/amount of money in the piggy bank.
double balance;
//Is used to store the current state of the piggy bank(smashed or not, with smashed being true and not smashed being false).
bool smashedState;
//The default consturcotr.
PiggyBank():balance(0.0),smashedState(false){}
//Parameter consructor to obtain/assign the starting balance in the piggy bank.
PiggyBank(double initialAmount):balance(initialAmount),smashedState(false)
{
//If statemnt to handle the case when the balance is negative.
if(initialAmount <0.0)
{
std::cerr<<"Cannot have a negative balance of $"<0.0))
{
balance += amount;
}
else
{
//Seperate if stamentes that handle the indivudal conditions/cases that would prevent a successful deposit,
//and then prints a corresponding error message to the console.
if(smashedState)
{
std::cerr<<"Cannot deposit money into a broken bank
";
return;
}
if(amount <0.0)
{
std::cerr<<"Cannot deposit negative
";
return;
}
}
}
//This function is used to withdraw a specified amount of money.
void withdraw(double amount)
{
//A withdraw will only be succesful if the piggy bank is not smashed, the amount to be withdrawn is not negative,
//and the amount to be withdrawn is not greater than the amount of money in the piggy bank.
if((!smashedState)&&(amount >0.0)&&(balance>=amount))
{
balance -= amount;
}
else
{
//Indivudal if statements that test for the different condtions that will cause a withdraw to fail, and then prints out
//a coreesponding error message to the console.
if(smashedState)
{
std::cerr<<"Cannot withdraw money from a broken bank
";
return;
}
if(amount <0.0)
{
std::cerr<<"Cannot withdraw negative
";
return;
}
if(amount > balance)
{
std::cerr<<"Cannot withdraw more money than is available
";
return;
}
}
}
//This fucntion will smash the piggy bank when it is called.
void smash()
{
//If statement that will print an error message stating how much money was lost, but will only execute if there
//was a non negative, non zero amount of money in the piggy bank.(It will only print an error message if you actually lost money).
if(balance >0.0)
{
std::cout<<"NOOO!!! You lost $"<

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!