Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

java code Exercise 1. Create a class named Account that includes one instance variable - balance (type double). a. Provide a constructor that initializes the

java code
image text in transcribed
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

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

Step: 3

blur-text-image

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

Oracle Database 10g Insider Solutions

Authors: Arun R. Kumar, John Kanagaraj, Richard Stroupe

1st Edition

0672327910, 978-0672327919

More Books

Students also viewed these Databases questions