Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

. . . Create a class called Account and has 2 instance variables 1. ID as an Integer 2. Balance as a Double Your class

image text in transcribedimage text in transcribedimage text in transcribed

. . . Create a class called Account and has 2 instance variables 1. ID as an Integer 2. Balance as a Double Your class should have a constructor that take the ID and an initial Balance and use it to initialize the balance amount. Your constructor should validate that the initial Balance is greater than 0, otherwise balance should be initialized to the default value 0.0. Provide a set and a get method for each instant variable Add a method called deposit that add an amount to the account's balance. It also should print the updated balance. Add a method called debit that withdraws money from an account. Ensures that the debit amount does not exceed the account's and if it does the method should keep the balance as it is and print a message to the user indicating that "The debit amount exceeded account balance". Then the method should ask the user to enter another amount or (0) to exit. If the withdraw amount is correct the method should print the updated balance. Write a class called TestAccount with a main method in this method you will create an object of the class account. Prompt the user to enter the id and the initial balance Then ask the user for the wanted operation (show balance, deposit or debit) and perform it. . . . Lab Assessment.pdf O File /Users/rahaf/Downloads/Lab2Assessment.pdf Not syncing 1 of 2 Q O Page view | A Read aloud | Draw Highlight Erase Object Oriented Programming - 14011102-4 Complete the following tasks in Java using NetBeans. Create a class called Account and has 2 instance variables 1. ID as an Integer 2. Balance as a Double Your class should have a constructor that take the ID and an initial Balance and use it to initialize the balance amount. Your constructor should validate that the initial Balance is greater than 0, otherwise balance should be initialized to the default value 0.0. Provide a set and a get method for each instant variable Add a method called deposit that add an amount to the account's balance. It also should print the updated balance. Add a method called debit that withdraws money from an account. Ensures that the debit amount does not exceed the account's and if it does the method should keep the balance as it is and print a message to the user indicating that "The debit amount exceeded account balance". Then the method should ask the user to enter another amount or (0) to exit. If the withdraw amount is correct the method should print the updated balance. Write a class called TestAccount with a main method in this method you will create an object of the class account. Prompt the user to enter the id and the initial balance Then ask the user for the wanted operation (show balance, deposit or debit) and perform it Lab Assessment.pdf + O File /Users/rahaf/Downloads/Lab2Assessment.pdf Not syncing 2 of 2 Q + D Page view | A Read aloud Draw Highlight Erase w Fun: Please enter your account ID 999999 Please enter your initial balance : 500 Select a ratton 1 ! show Ya Balance 1: Withdrat. 4: To exit Your choice 1 1 Your current balance 30.5 Select an operation I show your Balance 2 : Deposit an amount 3Withdraw out. 4: TAKT Your choice Dla tua sunt le posit 200 Your updated balance is 700.0 Belect an operation: 1 : Show your Balance 2 : Depoest an amount. 3: Withdraw an out. to exit Your chose1 Enter the amount you want to withdraw: 800 The debut wount exceeded account balance.. Would you like to try the amount to to exit, 1 to continue) 1 Enter the amount you want to withdrav! 700 Your updated balance is 0.0 Select an operation: 1 : Show yorar Talance. 2 : Deposit an amount. 3 without Your cho 4 BUILD 800C0BSEUL (total time l xinute 30 seconds)

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

Introduction To Constraint Databases

Authors: Peter Revesz

1st Edition

1441931554, 978-1441931559

More Books

Students also viewed these Databases questions