Question

Using C++ Please make sure you comment each section of the program so I can better...

Using C++

Please make sure you comment each section of the program so I can better understand it. Thank you!

Assignment Content

  1. You are now working for a bank, and one of your first projects consists of developing an application to manage savings accounts.

    Create a C++ program that does the following:

    • Creates a SavingsAccount class
    • Uses a static data member, annualInterestRate, to store the annual interest rate for each of the savers
    • Ensures each member of the class contains a private data member, savingsBalance, indicating the amount the saver currently has on deposit
    • Develops a member function, calculateMonthlyInterest, to calculate the monthly interest by multiplying the savingsBalance by annualInterestRate divided by 12; this interest should then be added to savingsBalance
    • Develops a static member function, modifyInterestRate, that sets the static annualInterestRate to a new value
    • Instantiates two different objects of class SavingsAccount, Firstsaver and Secondsaver, with balances of $1000.00 and $2000.00, respectively; set the annualInterestRate to 2 percent
    • Calculates the monthly interest and prints the new balances for each of the savers
    • Sets the annualInterestRate to 3 percent, calculates the next month's interest, and prints the new balances for each of the savers

    Include the proper header and make sure you properly comment your program. Also, make sure you use proper coding conventions.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code:

#include <iostream>

using namespace std;

//SavingsAccount.h
class SavingAccount
{
public:
   SavingAccount(float savingsBal);
   ~SavingAccount();
   void calculateMonthlyInterest();
   static void modifyInterestRate(float newInterest);
   void printSavings();
private:
   static float annualInterestRate;
   float savingsBalance;
};

//SavingsAccount.cpp

float SavingAccount::annualInterestRate = 2;

SavingAccount::SavingAccount(float savingsBal):savingsBalance(savingsBal)
{
}

SavingAccount::~SavingAccount()
{
}

void SavingAccount::calculateMonthlyInterest()
{
   //Calculate the monthly Interest according to the formulae
   float monthlyInterest = (savingsBalance * annualInterestRate) / (12 * 100);
   savingsBalance += monthlyInterest;
}

void SavingAccount::modifyInterestRate(float newInterest)
{
   //Sets the new Interest Rate
   annualInterestRate = newInterest;
}

void SavingAccount::printSavings()
{
   //Print the Balance
   cout << "\nSavings Account Balance : " << savingsBalance;
}

int main()
{
   //Instantiating two Instances of the savingsAccount class
   //On the process pass the initial savings balance as the constructor argument
   SavingAccount firstSaver(1000.00), secondSaver(2000.00);

   //Calculate the Monthly Interest for two Savers
   firstSaver.calculateMonthlyInterest();
   secondSaver.calculateMonthlyInterest();

   //Print the new Balances for the two savers
   firstSaver.printSavings();
   secondSaver.printSavings();

   //change the annual Interest Rate
   SavingAccount::modifyInterestRate(3);

   //Calculate the Monthly Interest for two Savers
   firstSaver.calculateMonthlyInterest();
   secondSaver.calculateMonthlyInterest();

   //Print the new Balances for the two savers
   firstSaver.printSavings();
   secondSaver.printSavings();

   return 0;
}

OUTPUT:

Add a comment
Know the answer?
Add Answer to:
Using C++ Please make sure you comment each section of the program so I can better...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C# How to Program: 10.5 Savings account class

    Create the class savings account. Use the static variable annualInterestRate to store the annual interest rate for all account holders. Each object of the classcontains a private instance variable savingsBalance, indicating the amount the saver currently has on deposit. Provide method CalculateMonthlyInterest to calculate themonthly interest by multiplying the savingsBalance by annualInterestRate divided by 12, this interest should be added to savingsBlance, Provide static methodModifyInterestRate to set the annualInterestRate to a new value. Write an application to test class SavingsAccount....

  • Create a .java file that has class SavingsAccount. Use a static variable annualInterestRate to store the...

    Create a .java file that has class SavingsAccount. Use a static variable annualInterestRate to store the annual interest rate for all account holders. Each object of the class contains a private instance variable savingsBalance indicating the amount the saver currently has on deposit. Provide method calculateMonthlyInterest to calculate the monthly interest by multiplying the savingsBalance by annualInterestRate divided by 12- this interest should be added to savingsBalance. Provide a static method setInterestRate that sets the annualInterestRate to a new value....

  • JAVA Create a class called SavingsAccount. The class should have a static variable named, annualInterestRate, to...

    JAVA Create a class called SavingsAccount. The class should have a static variable named, annualInterestRate, to store the annual interest rate for all account holders. Each object of the class should contain a private instance variable named, savingsBalance, indicating the amount the saver currently has on deposit. Write methods to perform the following: calculateMonthlyInterest – calculates the monthly interest by multiplying the savingsBalance by annualInterestRate divided by 12. This interest should be added to the balance. depositAmount – allows the...

  • Code should be in C# Create a class called SavingsAccount.  Use a static variable called annualInterestRate to...

    Code should be in C# Create a class called SavingsAccount.  Use a static variable called annualInterestRate to store the annual interest rate for all account holders.  Each object of the class contains a private instance variable savingsBalance, indicating the amount the saver currently has on deposit. Provide method CalculateMonthlyInterest to calculate the monthly interest by multiplying the savingsBalance by annualInterestRate divided by 12 – this interest should be added to savingsBalance.  Provide static method setAnnualInterestRate to set the annualInterestRate to a new value....

  • Application should be in C# programming language Create a class called SavingsAccount.  ...

    Application should be in C# programming language Create a class called SavingsAccount.  Use a static variable called annualInterestRate to store the annual interest rate for all account holders.  Each object of the class contains a private instance variable savingsBalance, indicating the amount the saver currently has on deposit. Provide method CalculateMonthlyInterest to calculate the monthly interest by multiplying the savingsBalance by annualInterestRate divided by 12 – this interest should be added to savingsBalance.  Provide static method setAnnualInterestRate to set the...

  • a) Create saving account Class. Use a static data member annualBonusRate to store the annual bonus...

    a) Create saving account Class. Use a static data member annualBonusRate to store the annual bonus rate for each of the savers (objects) b) The class contains a private data member savingBalance indicating the amount the saver currently has on deposit. c) Provide member function calculate MonthlyBonus that calculates the monthly bonus by multiplying the savingBalance by annualBonusRate divided by 12; this bonus should be addad to savingBalance. d) Provide a static member function modifyBunusRate that has a parameter and...

  • please put the comment each line, make sure i will have output too. write a program,...

    please put the comment each line, make sure i will have output too. write a program, Summarize (Summarize.java), containing the main() method, that first writes 10,000 random positive double type numbers, to the full accuracy of the number (15/16 decimal places), to a text file named DataValues.txt, one number per line. The program must then close that file, and reopen it for reading. Read back the values from the file and write the following information to a file named Summary.txt:...

  • C++ Help. PLEASE include detailed comments and explanations. PLEASE follow the drections exactly. Thank you. Define...

    C++ Help. PLEASE include detailed comments and explanations. PLEASE follow the drections exactly. Thank you. Define a class with the name BankAccount and the following members: Data Members: accountBalance: balance held in the account interestRate: annual interest rate. accountID: unique 3 digit account number assigned to each BankAccount object. Use a static data member to generate this unique account number for each BankAccount count: A static data member to track the count of the number of BankAccount objects created. Member...

  • In C++ Write a program that contains a BankAccount class. The BankAccount class should store the...

    In C++ Write a program that contains a BankAccount class. The BankAccount class should store the following attributes: account name account balance Make sure you use the correct access modifiers for the variables. Write get/set methods for all attributes. Write a constructor that takes two parameters. Write a default constructor. Write a method called Deposit(double) that adds the passed in amount to the balance. Write a method called Withdraw(double) that subtracts the passed in amount from the balance. Do not...

  • New to python if you can add screenshort also, i am using python 3 7.3 (The...

    New to python if you can add screenshort also, i am using python 3 7.3 (The Account class) Design a class named Account that contains A private int data field named id for the account. A private float data field named annualInterestRate that stores the current A constructor that creates an account with the specified id (default 0), initial The accessor and mutator methods for id, balance, and annualInterestRate A private float data field named balance for the account. interest...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT