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 0.
Add a public property for the AccountNumber (read-only) and Balance (read-only).
Create the following methods:
Deposit(double amount): Adds the amount to the Balance.
Withdraw(double 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 blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!