Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

Create a class called Account that contains: Three private instance variables: name (String), account (String), account balance (double). One constructor, which constructs all instances with

Create a class called Account that contains:

Three private instance variables: name (String), account (String), account balance (double).

One constructor, which constructs all instances with the values given.

Getters and setters for all the instance variables.

Debit function that takes an amount from the user and subtract the balance (make sure the balance will not drop below zero after the operation, if this was the case, the function should return false else it should return true)

Credit function that takes an amount from the user and add it to the balance.

Write a test program called TestAccount to test the constructor and public methods in the class Account. Ask the user to enter the information for four accounts and create them, then allow the user to choose the operation that he wants on those accounts. Operations are Show balance or Debit or Credit, if he chose debit or credit ask him to specify the amount, in case of debit if the amount is not sufficient tell him insufficient amount.image text in transcribed

Enter Name: Ali Moussa Enter Account Number: 11223344 Enter Balance: 1000 Enter Name: Mohammed Omran Enter Account Number: 22334455 Enter Balance: 1500 Enter Name: Hassan Youssef Enter Account Number: 33445566 Enter Balance: 200 Enter Name: Yasser Mustafa Enter Account Number: 44556677 Enter Balance: 2000 Which account you wish to process? 3 Choose your operation 1. Show Balance 2. Debit 3. Credit Enter Amount: 50 Your new balance is 150 Which account you wish to process? 3 Choose your operation: 1. Show Balance 2. Debit 3. Credit Enter Amount: 170 Insufficient Balance Which account you wish to process? 3 Choose your operation: 1. Show Balance 2. Debit 3. Credit Your balance is 150

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image
Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Students explore these related Databases questions