Using Cpp/C++ Create an Account class that a bank might use to represent customers’ bank accounts. Include a data member of type int to represent the account balance. [Note: In subsequent chapters, we’ll use numbers that contain decimal points (e.g., 2.75)—called floating-point values— to represent dollar amounts.] Provide a constructor that receives an initial balance and uses it to initialize the data member. The constructor should validate the initial balance to ensure that it’s greater than or equal to 0. If not, set the balance to 0 and display an error message indicating that the initial balance was invalid. Provide three member functions. Member function credit should add an amount to the current balance. Member function debit should withdraw money from the Account and ensure that the debit amount does not exceed the Account’s balance. If it does, the balance should be left unchanged and the function should print a message indicating "Debit amount exceeded account balance." Member function getBalance should return the current balance. Create a program that creates two Account objects and tests the member functions of class Account.

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter11: More Object-oriented Programming Concepts
Section: Chapter Questions
Problem 1GZ
icon
Related questions
Question

Using Cpp/C++ Create an Account class that a bank might use to represent customers’ bank
accounts. Include a data member of type int to represent the account balance. [Note: In subsequent
chapters, we’ll use numbers that contain decimal points (e.g., 2.75)—called floating-point values—
to represent dollar amounts.] Provide a constructor that receives an initial balance and uses it to initialize
the data member. The constructor should validate the initial balance to ensure that it’s greater
than or equal to 0. If not, set the balance to 0 and display an error message indicating that the initial
balance was invalid. Provide three member functions. Member function credit should add an
amount to the current balance. Member function debit should withdraw money from the Account
and ensure that the debit amount does not exceed the Account’s balance. If it does, the balance
should be left unchanged and the function should print a message indicating "Debit amount exceeded
account balance." Member function getBalance should return the current balance. Create a
program that creates two Account objects and tests the member functions of class Account. 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Reference Types in Function
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
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,