Starting Out with C++ from Control Structures to Objects (9th Edition)
Starting Out with C++ from Control Structures to Objects (9th Edition)
9th Edition
ISBN: 9780134498379
Author: Tony Gaddis
Publisher: PEARSON
bartleby

Concept explainers

Question
Book Icon
Chapter 15, Problem 14PC
Program Plan Intro

Bank Accounts

Program plan:

Savings.h:

  • Include the required header files.
  • Define a class for “saving”
  • In protected, declare the required variable.
  • In public, declare a constructor and declare the functions “withdraw()”, “deposit()” and “monthlyProc()” function.

Savings.cpp:

  • Function definition for the “withdraw()”of savings class..
    • Check whether the status is “false”.
      • Display the statement.
    • Check whether the amount is less than 0
    • Check the condition for deactivation.
    • Check the condition or withdraw amount.
      • Make a call to the function “withdraw()”
  • Function definition for the “deposit()”of savings class..
    • Check the “bal” is greater than 25.
      • Assign the “status” to “true”.
      • Make a call to the base class function “deposit()”.
  • Function definition for the “monthlyProc()” of savings class.
    • Check whether the “withdraw_amt” is greater than 4.
      • Calculate the service charge.
    • Call the function “monthlyProc()”.
    • Call the function “getMonthlyStats()”

Checking.cpp:

  • Function definition for the “withdraw()” of checking class.
    • Check whether the status is “false”.
      • Display the statement.
    • Check whether the amount is less than 0
    • Check the condition for deactivation.
    • Check the condition or withdraw amount.
      • Make a call to the function “withdraw()”
  • Function definition for the “deposit()”of checking class..
    • Check the “bal” is greater than 25.
      • Make a call to the base class function “deposit()”.
  • Function definition for the “monthlyProc()”of checking class..
    • Check whether the “withdraw_amt” is greater than 4.
      • Calculate the service charge.
    • Call the function “monthlyProc()”.
    • Call the function “getMonthlyStats()”

Checking.h:

  • Define the “ Checking.h”.
  • In public, declare the base class constructor.
  • Declare the functions “withdraw()”, “deposit()” and “monthlyProc()”.

Account.h:

  • Define the “Account.h”.
  • In protected, declare the required variables.
  • In public, invoke the constructor. And declare the functions “withdraw()”, “deposit()” and “monthlyProc()”.

Account.cpp:

  • Create a constructor “Account()” and initialize the variables.
  • Function definition for “deposit()” of Account class.
    • Add the “amount” with the “bal” amount.
    • Increment the “dep_amt”.
  • Function definition for “withdraw” of Account class.
    • Subtract the “amount” with the “bal” amount.
    • Increment the “withdraw_amt”.
  • Function definition for “calcInt()”.
    • Calculate the monthly interest rate.
    • Add the “mon_interest” with “bal” amount.
  • Function definition for “monthlyProc()”.
    • Call the function “calcInt()”.
    • Subtract the “ser_charge” with “bal”.
  • Function definition for “getMonthlyStats()”.
    • Display the withdraw amount, deposit amount, service charges and ending balance.

Soruce.cpp:

  • Include the required header files.
  • Define the main() function,
    • Include the required function prototype to the program.
      • Create an object for savings and checking.
      • Declare a variable to hold the user choice.
      • Display the menu options.
      • Validate the menu options.
      • Execute the user’s choice.
      • Use switch for selecting options.
        • Case 1:
          • Get the deposits amount.
          • Call the “deposit()” from the savings class.
        • Case 2:
          • Get the deposits amount.
          • Call the “deposit()” from the checking class.
        • Case 3:
          • Get the withdraw amount.
          • Call the “withdraw()” from the saving class.
        • Case 4:
          • Get the withdraw amount.
          • Call the “withdraw()” from the checking class.
        • Case 5:
          • Call the “ignore()” then call the “monthlyProc()” from the savings class.
          • Call the “get()” then call the “monthlyProc()” from the checking class.

Blurred answer
Students have asked these similar questions
(In C++)   This program should be designed and written by a team of students.  Here are some suggestions: You may work on a single class. The parameter and return type s of each function and class member function should be decided in advance. The program will be best implemented as a multi-file program, (header file, the main program,..) You need to print all output to an output file and submit it to the instructor during the final exam. Design a generic class to hold the following information about a bank account: Balance Number of deposits this month Number of withdrawals  Annual Interest Rate Monthly service charges The class should have the following member function:                 Constructors  Accepts arguments for the balance and annual interest rate.      deposit     a virtual function that accepts an argument for the amount of the deposit.  The function should add the argument to the account balance.  It should also increment the variable holding the…
(Polynomial Class) Develop class Polynomial. The internal representation of a Polynomialis an array of terms. Each term contains a coefficient and an exponent, e.g., the term2x4has the coefficient 2 and the exponent 4. Develop a complete class containing proper constructorand destructor functions as well as set and get functions. The class should also provide the followingoverloaded operator capabilities:a) Overload the addition operator (+) to add two Polynomials.b) Overload the subtraction operator (-) to subtract two Polynomials.c) Overload the assignment operator to assign one Polynomial to another.d) Overload the multiplication operator (*) to multiply two Polynomials.e) Overload the addition assignment operator (+=), subtraction assignment operator (-=),and multiplication assignment operator (*=).
Pointer and classImplement a class called Team as specified:data members:name - the name of the Team (defined as a dynamic variable)members - a dynamic array of stringsize - number of members in the team.functions:Course(): default constructor set name to “TBD”, and size to 0, members toempty listCourse(string): one argument constructor set name, and size to 0, members toempty listaccessor - an accessor for the name and size variablemutator - an mutator for the name variableUse following main() to test your class.int main() {Team a,b("Mets");cout<<a.getName()<<endl; // print TBDa.setName("Yankee");cout<<a.getName()<<endl; // print Yankeecout<<b.getName()<<endl; // print Metscout<<a.getSize()<<endl; // print 0return 0;}

Chapter 15 Solutions

Starting Out with C++ from Control Structures to Objects (9th Edition)

Ch. 15.7 - Prob. 15.11CPCh. 15.7 - What will the following program display? #include...Ch. 15.7 - What will the following program display? #include...Ch. 15.7 - What will the following program display? #include...Ch. 15.7 - What will the following program display? #include...Ch. 15.8 - Does the following diagram depict multiple...Ch. 15.8 - Does the following diagram depict multiple...Ch. 15.8 - Examine the following classes. The table lists the...Ch. 15.8 - Examine the following class declarations: class...Ch. 15 - What is an is a relationship?Ch. 15 - A program uses two classes: Dog and Poodle. Which...Ch. 15 - How does base class access specification differ...Ch. 15 - What is the difference between a protected class...Ch. 15 - Can a derived class ever directly access the...Ch. 15 - Which constructor is called first, that of the...Ch. 15 - What is the difference between redefining a base...Ch. 15 - Prob. 8RQECh. 15 - What is an abstract base class?Ch. 15 - A program has a class Potato, which is derived...Ch. 15 - What base class is named in the line below?class...Ch. 15 - What derived class is named in the line below?...Ch. 15 - What is the class access specification of the base...Ch. 15 - What is the class access specification of the base...Ch. 15 - Protected members of a base class are like...Ch. 15 - Complete the table on the next page by filling in...Ch. 15 - Complete the table below by filling in private,...Ch. 15 - Complete the table below by filling in private,...Ch. 15 - A derived class inherits the ________ of its base...Ch. 15 - When both a base class and a derived class have...Ch. 15 - An overridden base class function may be called by...Ch. 15 - When a derived class redefines a function in a...Ch. 15 - A(n) __________ member function in a base class...Ch. 15 - ________ binding is when the compiler binds member...Ch. 15 - __________ binding is when a function call is...Ch. 15 - _________ is when member functions in a class...Ch. 15 - When a pointer to a base class is made to point to...Ch. 15 - A(n) __________ class cannot be instantiated.Ch. 15 - A(n) _______ function has no body, or definition,...Ch. 15 - A(n) _________ of inheritance is where one class...Ch. 15 - _______ is where a derived class has two or more...Ch. 15 - In multiple inheritance, the derived class should...Ch. 15 - Write the first line of the declaration for a...Ch. 15 - Write the first line of the declaration for a...Ch. 15 - Suppose a class named Tiger is derived from both...Ch. 15 - Write the declaration for class B. The classs...Ch. 15 - T F The base classs access specification affects...Ch. 15 - T F The base classs access specification affects...Ch. 15 - T F Private members of a private base class become...Ch. 15 - T F Public members of a private base class become...Ch. 15 - T F Protected members of a private base class...Ch. 15 - T F Public members of a protected base class...Ch. 15 - T F Private members of a protected base class...Ch. 15 - T F Protected members of a public base class...Ch. 15 - T F The base class constructor is called after the...Ch. 15 - T F The base class destructor is called after the...Ch. 15 - T F It isnt possible for a base class to have more...Ch. 15 - T F Arguments are passed to the base class...Ch. 15 - T F A member function of a derived class may not...Ch. 15 - Prob. 51RQECh. 15 - T F A base class may not be derived from another...Ch. 15 - class Car, public Vehicle { public: Car(); Car();...Ch. 15 - class Truck, public : Vehicle, protected {...Ch. 15 - class SnowMobile : Vehicle { protected: int...Ch. 15 - class Table : public Furniture { protected: int...Ch. 15 - class Tank : public Cylinder { private: int...Ch. 15 - class Three : public Two : public One { protected:...Ch. 15 - Employee and ProductionWorker Classes Design a...Ch. 15 - ShiftSupervisor Class In a particular factory, a...Ch. 15 - TeamLeader Class In a particular factory, a team...Ch. 15 - Prob. 4PCCh. 15 - Time Clock Design a class named TimeClock. The...Ch. 15 - Essay Class Design an Essay class that is derived...Ch. 15 - PersonData and CustoraerData Classes Design a...Ch. 15 - PreferredCustomer Class A retail store has a...Ch. 15 - File Filter A file filter reads an input file,...Ch. 15 - File Double-Spacer Create a derived class of the...Ch. 15 - Course Grades In a course, a teacher gives the...Ch. 15 - Ship. CruiseShip, and CargoShip Classes Design a...Ch. 15 - Pure Abstract Base Class Project Define a pure...Ch. 15 - Prob. 14PC
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,