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....

  • 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...

  • 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...

  • Write a C++ program for the instructions below. Please read the instructions carefully and make sure they are followed correctly.   please put comment with code! and please do not just copy other solu...

    Write a C++ program for the instructions below. Please read the instructions carefully and make sure they are followed correctly.   please put comment with code! and please do not just copy other solutions. Instructions 1. Read instructions carefully! 2. Use C++ syntax only, C syntax will not be accepted. 3. Always use braces to define blocks. 4. Indent all lines within a block. Each block requires one more tab. 5. Organize your code well with proper formatting and a single...

  • C - language please 1. Create a program that does the following, make sure you can...

    C - language please 1. Create a program that does the following, make sure you can complete this before moving to further questions, when compiling add the -Ipthread argument, if you are using gcc use the -pthread argument. Creates two threads, the first uses a function hello world() which prints hello world, the second uses a function goodbye() which prints goodbye. • Each function has a random sleep duration before printing the output - After running your program a few...

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
ADVERTISEMENT