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....
(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...
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++ 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)...
Program in C++ **********Write a program to compute the number of collisions required in a long...
Program in C++ **********Write a program to compute the number of collisions required in a long random sequence of insertions using linear probing, quadratic probing and double hashing. For simplicity, only integers will be hashed and the hash function h(x) = x % D where D is the size of the table (fixed size of 1001). The simulation should continue until the quadratic hashing fails.*********
c++ The above Account class was created to model a bank account. An account has the...
c++ The above Account class was created to model a bank account. An account has the properties (keep the properties private) account number, balance, and annual interest rate, date created, and functions to deposit and withdraw. Create two derived classes for checking and saving accounts. A checking account has an overdraft limit, but a savings account cannot be overdrawn. Define a constant virtual toString() function in the Account class and override it in the derived classes to return the account...
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.
what is the current account balance? what does a current account deficit do that is positive...
what is the current account balance? what does a current account deficit do that is positive for a nation? are here any thresholds between safe and dangerous levels of a deficit? (use the main accounting identity)
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT