Question: Create a class that simulates a simple bank account, including methods to deposit and withdraw money. Instructions: Define a BankAccount class: The class should have
Create a class that simulates a simple bank account, including methods to deposit and withdraw money.
Instructions:
Define a BankAccount class:
The class should have the following private fields:
int AccountNumber
double Balance
Create a constructor that takes an accountNumber as a parameter and initializes the Balance to
Add a public property for the AccountNumber readonly and Balance readonly
Create the following methods:
Depositdouble amount: Adds the amount to the Balance.
Withdrawdouble amount: Subtract the amount from the Balance if the Balance is sufficient, otherwise, print a message indicating insufficient funds.
PrintBalance: Prints the current balance.
Create a Main method:
In the Main method, create a BankAccount object with a specific account number.
Call the Deposit method to add money to the account.
Call the Withdraw method to try withdrawing some money.
Call PrintBalance to show the account's balance.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
