Exercise 1: Give a C++ class declaration called SavingsAccount with the following information: Operations (Member Functions) 1. Open account (with an initial deposit). This is called to put initial values in dollars and cents. 2. Make a deposit. A function that will add value to dollars and cents 3. Make a withdrawal. A function that will subtract values from dollars and cents. 4. Show current balance. A function that will print dollars and cents. Data (Member Data) 1. dollars 2. cents Give the implementation code for all the member functions. NOTE: You must perform normalization on cents. This means that if cents is 100 or more, it must increment dollars by the appropriate amount. Example: if cents is 234, then dollars must be increased by 2 and cents reduced to 34. Write code that will create an object called bank1. The code will then initially place $200.50 in the account. The code will deposit $40.50 and then withdraw $100.98. It will print out the final value of dollars and cents. The following output should be produced: Dollars = 140 Cents = 2. Change the program to allow the user to input the initial values, deposit and withdrawal. Example: ******Photo*********   Replace the initial member function by two constructors. One constructor is the default constructor that sets both dollars and cents to 0. The other constructor has 2 parameters that set dollars and cents to the indicated values. Have the code generate two objects: bank1 (which has its values set during definition by the user) and bank2 that uses the default constructor. Have the code input deposits and withdrawals for both bank1 and bank2.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Exercise 1: Give a C++ class declaration called SavingsAccount with the following information:

Operations (Member Functions)
1. Open account (with an initial deposit). This is called to put initial values in

dollars and cents.

2. Make a deposit. A function that will add value to dollars and cents

3. Make a withdrawal. A function that will subtract values from dollars and cents.

4. Show current balance. A function that will print dollars and cents.

Data (Member Data) 1. dollars
2. cents

Give the implementation code for all the member functions.
NOTE: You must perform normalization on cents. This means that if cents

is 100 or more, it must increment dollars by the appropriate amount. Example: if cents is 234, then dollars must be increased by 2 and cents reduced to 34.

Write code that will create an object called bank1. The code will then initially place $200.50 in the account. The code will deposit $40.50 and then withdraw $100.98. It will print out the final value of dollars and cents.

The following output should be produced:

Dollars = 140 Cents = 2.

Change the program to allow the user to input the initial values, deposit and withdrawal.

Example: ******Photo*********

 

Replace the initial member function by two constructors. One constructor is the default constructor that sets both dollars and cents to 0. The other constructor has 2 parameters that set dollars and cents to the indicated values.

Have the code generate two objects: bank1 (which has its values set during definition by the user) and bank2 that uses the default constructor. Have the code input deposits and withdrawals for both bank1 and bank2.

Example:
Please input the initial dollars
402
Please input the initial cents
78
Would you like to make a deposit? Y or y for yes
y
Please input the dollars to be deposited
35
Please input the cents to be deposited
67
Would you like to make a deposit? Y or y for yes
y
Please input the dollars to be deposited
35
Please input the cents to be deposited
67
Would you like to make a deposit? Y or y for yes
Would you li ke to make a withdrawal Y or y for yes
y
Please input the dollars to be withdrawn
28
Please input the cents to be withdrawn
08
Would you like to make a withdrawal Y or y for yes
y
Please input the dollars to be withdrawn
75
Please input the cents to be withdrawn
78
Would you like to make a withdrawal Y or y for yes
n
Dollars = 370 Cents = 26
Transcribed Image Text:Example: Please input the initial dollars 402 Please input the initial cents 78 Would you like to make a deposit? Y or y for yes y Please input the dollars to be deposited 35 Please input the cents to be deposited 67 Would you like to make a deposit? Y or y for yes y Please input the dollars to be deposited 35 Please input the cents to be deposited 67 Would you like to make a deposit? Y or y for yes Would you li ke to make a withdrawal Y or y for yes y Please input the dollars to be withdrawn 28 Please input the cents to be withdrawn 08 Would you like to make a withdrawal Y or y for yes y Please input the dollars to be withdrawn 75 Please input the cents to be withdrawn 78 Would you like to make a withdrawal Y or y for yes n Dollars = 370 Cents = 26
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Data members
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
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education