Question: java code Exercise 1. Create a class named Account that includes one instance variable - balance (type double). a. Provide a constructor that initializes the
Exercise 1. Create a class named Account that includes one instance variable - balance (type double). a. Provide a constructor that initializes the account object with balance, if the balance is less than 0.0 make the balance to zero or else assign balance. b. Add a three methods credit, debit and getBalance. - The credit method receives one parameter amount (Type double) that will add to the balanace. - The debit that withdraws money from an account. Ensure that the debit amount does not exceed the Account's balance. If it does, the balance should be left unchanged and the method should print a message indicating "Debit amount exceeded account balance." - The getBalance method returns balance of a particular Account's object's balance. Write a test application named AccountTest that demonstrates class Account's capabilities. 1. Create account 2. Credit to account 3. Debit from account 4. Check balance 5. Quit Select your option: 1 Enter starting balance: 100 Account created with starting balance of SAR 100.00 Select your option: 2 Enter the amount to credit: 50 SAR 50.00 credited to your account. The balance of your account is SAR 150,00 Select your option: 3 Enter the amount to debit: 20 SAR 20,00 has been debited fxom your accourt. The balance of your account is SAR 130.00 Select your option: A The balance of youf account da SAt 130,00 Beleot your option: is Bye
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
