Question

In: Computer Science

*********C++ Program************ Enhance the Account class to compute the interest on the current balance. An account...

*********C++ Program************

Enhance the Account class to compute the interest on the current balance. An account has initial balance of $10,000.00, and 6% percent annual interest is compounded monthly until the investment is double.
Write a main function to determine the number of months to double the initial investment. Create function name "double investment" for this project. Create a menu to allow the user to enter the initial investment and the annual interest rate. Please create a header file(bank.h) and a cpp file (bank.cpp). Below is code provided that needs to be altered to add "double investment" function. Please include code and output screenshots to show validation of functionality. Thank you!

#include <iostream>

using namespace std;

//public class

class Account{

public:

//instance variables

double amount;

  

//creates account and sets amount with users account set-up value

Account(double a){

amount = a;

}

  

//adds to amount in account once deposited

void deposit(double a){

if(a < 0){

return;

}

amount += a;

}

  

//decreases amount in account once withdrawn

void withdraw(double a){

if(amount-a < 0){

return;

}

amount -= a;

}

  

//returns balance of account

double get_balance(){

return amount;

}

};

Solutions

Expert Solution

`Hey,

Note: Brother if you have any queries related the answer please do comment. I would be very happy to resolve all your queries.

//bank.h

#ifndef BANK_H
#define BANK_H
class Account{

public:

//instance variables

double amount;
double rate;


//creates account and sets amount with users account set-up value

Account(double a,double r);

//adds to amount in account once deposited

void deposit(double a);

//decreases amount in account once withdrawn

void withdraw(double a);

//returns balance of account

double get_balance();
double investment();

};

#endif

//bank.cpp

#include "bank.h"
Account::Account(double a,double r){

amount = a;
rate=r;
}
void Account::deposit(double a){

if(a < 0){

return;

}

amount += a;

}

//decreases amount in account once withdrawn

void Account::withdraw(double a){

if(amount-a < 0){

return;

}

amount -= a;

}

//returns balance of account

double Account::get_balance(){

return amount;

}
double Account::investment()
{
int n=0;
double num=amount;
while(num<2.0*amount)
{
num=(1.0+rate/12.0)*num;
n=n+1;
}
return n;
}

//main.cpp

#include <iostream>
#include "bank.cpp"
using namespace std;

//public class


int main()
{

cout<<"Enter initial investment: ";
double amount;
cin>>amount;
cout<<"Enter percent rate: ";
double rate;
cin>>rate;
Account *p=new Account(amount,rate/100.0);
int n=p->investment();
cout<<"It takes "<<n<<" months to double the intial investment\n";

return 0;
}

Kindly revert for any queries

Thanks.


Related Solutions

C++ programming------------ Enhance the Account class to compute the interest on the current balance. An account...
C++ programming------------ Enhance the Account class to compute the interest on the current balance. An account has initial balance of $10,000.00, and 6% percent annual interest is compounded monthly until the investment is double. Write a main function to determine the number of months to double the initial investment. Create function name "double investment" for this project. Create a menu to allow the user to enter the initial investment and the annual interest rate. Please create a header file(Account.h) and...
Write a C++ program (The Account Class) Design a class named Account that contains (keep the...
Write a C++ program (The Account Class) Design a class named Account that contains (keep the data fields private): a) An int data field named id for the account. b) A double data field named balance for the account. c) A double data field named annualInterestRate that stores the current interest rate. d) A no-arg constructor that creates a default account with id 0, balance 0, and annualInterestRate 0. e) The accessor and mutator functions for id, balance, and annualInterestRate....
Question: Java Programming. ** Modify Current Program. Current Program class Account{       //instance variables   ...
Question: Java Programming. ** Modify Current Program. Current Program class Account{       //instance variables    private long accountNumber;    private String firstName;    private String lastName;    private double balance;       //constructor    public Account(long accountNumber, String firstName, String lastName, double balance) {        this.accountNumber = accountNumber;        this.firstName = firstName;        this.lastName = lastName;        this.balance = balance;    }    //all getters and setters    public long getAccountNumber() {        return...
(In C++) Bank Account Program Create an Account Class Create a Menu Class Create a main()...
(In C++) Bank Account Program Create an Account Class Create a Menu Class Create a main() function to coordinate the execution of the program. We will need methods: Method for Depositing values into the account. What type of method will it be? Method for Withdrawing values from the account. What type of method will it be? Method to output the balance of the account. What type of method will it be? Method that will output all deposits made to the...
in C++ Write a program to compute the current and the power dissipation in an AC...
in C++ Write a program to compute the current and the power dissipation in an AC circuit that has four resistors R1, R2, R3, and R4 in parallel. The voltage source is V. Test your solution with various voltage levels and resistor values. Execute and submit the program and the results in screen captures. Please note that the equivalent resistor is given by 1/Rtotal = 1/R1 + 1/R2 + 1/R3 + 1/R4 and the current I is given by I...
In the two-period model reviewed in class, both the Current Account and the Trade Balance in...
In the two-period model reviewed in class, both the Current Account and the Trade Balance in period 1 worsen (i.e., decrease) with an anticipated increase in the endowment of period two (ΔQ1=0 and ΔQ2>0)'' Use equations of the optimal allocation of consumption in periods 1 and 2, the trade balance in period 1 and the current account in period 1 to support your answer. No credit without explanation. For simplicity, assume the following lifetime utility function: U(C1,C2)= ln(C1) +β ln(C2)...
using C++ 23. Savings Account Balance Write a program that calculates the balance of a savings...
using C++ 23. Savings Account Balance Write a program that calculates the balance of a savings account at the end of a three- month period. It should ask the user for the starting balance and the annual interest rate. A loop should then iterate once for every month in the period, performing the following steps: A) Ask the user for the total amount deposited into the account during that month and add it to the balance. Do not accept negative...
I wrote a c++ program that is suppose to calculate the interest on a CD account...
I wrote a c++ program that is suppose to calculate the interest on a CD account but, I cant get the formula to calculate it correctly. please help. #include <iostream> #include <cmath> using namespace std; struct account { double balance; double interest_rate; int term; }; void info(account& accountinfo); int main(void) { double calc1, calc2; account accountinfo; info(accountinfo); calc1 = (accountinfo.interest_rate / 100) + 1; calc2 = pow(calc1, accountinfo.term); accountinfo.balance = accountinfo.balance * calc2; cout << " " << endl <<...
Accounting Program in c++ Write a class to keep track of a balance in a bank...
Accounting Program in c++ Write a class to keep track of a balance in a bank account with a varying annual interest rate. The constructor will set both the balance and the interest rate to some initial values (with defaults of zero). The class should have member functions to change or retrieve the current balance or interest rate. There should also be functions to make a deposit (add to the balance) or withdrawal (subtract from the balance). You should not...
Propose the similarities and differences of the current account and financial account in the balance of...
Propose the similarities and differences of the current account and financial account in the balance of payments structure. In doing so, apply your analysis to explain the trade balance between the U.S. and China.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT