Skip to content

CS 1415 - Lab #8

Objectives: 

  • Program with classes that use static members

Preparation: 

  • Review section 14.1 from Starting Out with C++ by Gaddis

Assignment: 

  1. Name your source files LlllFfffSavings.h, LlllFfffSavings.cpp, and LlllFfffLab08.cpp where Llll is the first four letters of your last name and Ffff is the first four letters of your first name.
  2. Design a SavingsAccount class. Use a static member variable for the interestRate. Each instance of the class contains a private member variable balance. The class should have a member function calcMonthlyInterest that calculates the interest earned for the month by multiplying balance by interestRate divided by 12 and adds it into balance. Provide a static member function setInterestRate that sets the static interestRate to a new value.
  3. Provide a driver program to test the SavingsAccount class. It should create two SavingsAccount objects. It should allow the user to enter the initial balances and initial interestRate. It should calculate and add in the monthly interest and print the new balances for each account. Then it should allow the user to set interestRate for the next month, calculate the second month's interest adding it tothe balance and print the new balances.
  4. Distribute the code appropriately among the three files: the header file, the implementation file, and the driver file.
  5. Verify your program works correctly.
  6. Submit your source code file to ude.wons@nosneros.htrag. Due at 8:00 am on 25 February