Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Will rate ASAP (Savings Account Class) Create a SavingsAccount class with the fo

ID: 3548527 • Letter: W

Question

Will rate ASAP


(Savings Account Class)

Create a SavingsAccount class with the following

specification

public:

SavingsAccount(float); //Constructor

void Transaction(float); //Procedure

float Total(float=0,int=0); //Savings Procedure

float TotalRecursive(float=0,int=0);

void toString(); //Output Properties

private:

float Withdraw(float); //Utility Procedure

float Deposit(float); //Utility Procedure

float Balance; //Property

int FreqWithDraw; //Property

int FreqDeposit; //Property


1) The constructor initilizes the balance if greater than

0 and sets the other properties to 0.

2) If the transaction is greater than 0 then a Deposit is

made else a Withdraw is made.

3) The balance is increased with a deposit but decreased

if a Withdrawal. This assumes the Withdrawal is less than

the balance. Can't have a negative balance. Tell the user

that he is trying to make a withdrawal that exceeds his

balance.

4) When a WithDrawal is made increment FreqWithDraw else

if a Deposit is made increment FreqDeposit.

5) The toString procedure outputs all properties.

6) The total procedure tells you how much you will have in

savings given the interest rate and the amount of time.

Total(float savint,int time) returns Balance*(1+savint)^time.

Utilize a for loop for this calculation.

7) See if you can write a recursive procedure that does

the same thing as 6). Call it TotalRecursive.

8) Think of what follows as pseudocode. The random number

generator below produces a number between 0 and 32,767. If

you fashion a random number that will do the same then you

will get positive and negative transactions (-500,500).

The output simply calculates the current balance with a 10

percent interest rate and 7 years worth of compounding.

Also, you tried to start out with a negative balance which

should have been initialized to 0.


SavingsAccount mine(-300);


for(int i=1;i<=10;i++)

{

mine.Transaction((float)(rand()%500)*(rand()%3-1));

}

mine.toString();

cout<<"Balance after 7 years given 10% interest = "

<<mine.Total((float)(0.10),7)<<endl;

cout<<"Balance after 7 years given 10% interest = "

<<mine.TotalRecursive((float)(0.10),7)

<<" Recursive Calculation "<<endl;


Example Output:

WithDraw not Allowed

WithDraw not Allowed

Balance=1056

WithDraws=4

Deposit=5

Balance after 7 years given 10% interest = 2057.85

Balance after 7 years given 10% interest = 2057.85 Recursive Calculation

Explanation / Answer

this is the program u want it is just that i didn`t understand the last tow things in the question but this is what i have done
#include<iostream>
#include<string>
#include<cmath>
using namespace std;

class saveAccount
{
public:
saveAccount(float); //Constructor
void Transaction(float); //Procedure
float Total(float,int); //Savings Procedure
float TotalRecursive(float=0,int=0);
void toString(); //Output Properties
private:
float Withdraw(float); //Utility Procedure
float Deposit(float); //Utility Procedure
float balance; //Property
int FreqWithDraw; //Property
int FreqDeposit; //Property
};
saveAccount::saveAccount(float num)
{
if(num>0)
balance=num;
else
balance=0;
FreqDeposit=FreqWithDraw=0;
}

void saveAccount::Transaction(float num)
{
if(num >0)
Deposit(num);
else
Withdraw(num);
}

float saveAccount::Deposit(float num)
{
balance=balance+num;
FreqDeposit++;
return balance;
}
float saveAccount::Withdraw(float num)
{
if((balance - num) >=0)
{
balance=balance-num;
FreqWithDraw++;
}
else
cout<<"the withdraw ammount is more than what you have"<<endl;
return balance;
}

void saveAccount::toString()
{
cout<<"the balance in your account is "<<balance<<endl;
cout<<"the Frequancy WithDraw is made ="<<FreqWithDraw<<endl;
cout<<"the Frequancy Deposit is made ="<<FreqDeposit<<endl;
}

float saveAccount::Total(float savint = 0, int time = 0)
{
float tot=0;
for(int i=1;i<=time;i++)
tot=tot+(balance*(1+savint));

return tot ;
}


void main()
{
saveAccount mine(-300);

for(int i=1;i<=10;i++)
{
mine.Transaction((float)(rand()%500)*(rand()%3-1));
}
mine.toString();
cout<<"Balance after 7 years given 10% interest = "
<<mine.Total((float)(0.10),7)<<endl;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote