Create a class called Account that a bank might use to represent customers' bank accounts. Your class should include one data member as int accountNumber and other of type float to represent the account balance. Your class should provide a default and parameterized constructor that receives an initial balance and accountNumber and uses it to initialize the data members. The constructor should validate the initial balance to ensure that it is greater than or equal to 0. If not, the balance should be set to 0 and the constructor should display an error message, indicating that the initial balance was invalid. The class should provide getter/setters for data members. The class should provide three member functions. Member function credit (float amount, int accountNumber) should add an amount to the current balance. Member function debit (float amount, int accountNumber) should withdraw money from the Account and should 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. Write a C++ program that creates an array of 5 Accounts, get values from user, and tests the member functions of class Account by providing following menu Credit Get Balance Then ask user to provide account number and amount to credit/debit then match account number with account number in array and then display balance of that account after credit/debit.
Create a class called Account that a bank might use to represent customers' bank accounts. Your class should include one data member as int accountNumber and other of type float to represent the account balance.
Your class should provide a default and parameterized constructor that receives an initial balance and accountNumber and uses it to initialize the data members.
The constructor should validate the initial balance to ensure that it is greater than or equal to 0. If not, the balance should be set to 0 and the constructor should display an error message, indicating that the initial balance was invalid.
The class should provide getter/setters for data members.
The class should provide three member functions.
Member function credit (float amount, int accountNumber) should add an amount to the current balance.
Member function debit (float amount, int accountNumber) should withdraw money from the Account and should 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.
Write a C++ program that creates an array of 5 Accounts, get values from user, and tests the member functions of class Account by providing following menu
- Credit
- Get Balance
Then ask user to provide account number and amount to credit/debit then match account number with account number in array and then display balance of that account after credit/debit.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 3 images