Answered You can buy a ready-made answer or pick a professional tutor to order an original one.

QUESTION

Ex 3.11 (Modified Account Class) Modify class Account (Fig. 3.8) to provide a method called withdraw that withdraws money from an Account. Ensure that the withdrawal amount does not exceed the Account

Ex 3.11 (Modified Account Class) Modify class Account (Fig. 3.8) to provide a method called withdraw that withdraws money from an Account. Ensure that the withdrawal 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 "Withdrawal amount exceeded account balance." Modify class AccountTest  (Fig. 3.9) to test method withdraw.

Ex : 3.12 (Invoice Class) Create a class called Invoice that a hardware store might use to represent an invoice for an item sold at the store. An Invoice should include four pieces of information as instance variables—a part number (type String), a part description (type String), a quantity of the item being purchased (type int) and a price per item (double). Your class should have a constructor that initializes the four instance variables. Provide a set and a get method for each instance variable. In addition, provide a method named getInvoiceAmount that calculates the invoice amount (i.e., multiplies the quantity by the price per item), then returns the amount as a double value. If the quantity is not positive, it should be set to 0. If the price per item is not positive, it should be set to Write a test app named InvoiceTest that demonstrates class Invoice’s capabilities.

Ex : 3.13 (Employee Class) Create a class called Employee that includes three instance variables—a first name (type String), a last name (type String) and a monthly salary (double). Provide a constructor that initializes the three instance variables. Provide a set and a get method for each instance variable. If the monthly salary is not positive, do not set its value. Write a test app named EmployeeTest that demonstrates class Employee’s capabilities. Create two Employee objects and display each  object’s yearly salary. Then give each Employee a 10% raise and display each Employee’s yearly salary again.

Show more
  • @
  • 22 orders completed
ANSWER

Tutor has posted answer for $10.00. See answer's preview

$10.00

** *** (Modified Account ****** Modify ***** ******* (Fig *** to ******* * method called ******** **** ********* money from ** ******* ****** that *** ********** ****** does *** ****** *** *********** ******* ** ** does the balance should ** **** ********* and *** ****** should print a ******* ********** "Withdrawal ****** ******** ******* ******** Modify ***** AccountTest **** 39) to test ****** withdrawSolution :Account ******** *** 38: ************* Account ***** with a ****** ******** ******** ******* *** * ************* *** deposit method that perform validation public ***** Account * ******* ****** name; ** instance ******** ******* ****** balance; ** ******** ********** ** Account *********** **** ******** *** ********** ****** ************** **** ****** ******** { ******** * ***** ** assign **** to instance ******** ****** ** ******** **** *** balance ** ******* **** *** ** **** *** ** instance ******** balance keeps its default initial ***** ** ** ** ******** **** *** ** if *** ******* is ***** *********** * ******** ** ****** ** ** ******** variable balance *** // method **** ******** ****** **** * ***** ****** ** *** balance public void deposit(double ************** * if ************** **** *** ** ** the ************* ** ***** ******* * ******* + depositAmount; ** *** ** ** *** balance *** public **** withdraw(double *************** *** ** *************** **** ******** * ******* * ******* * *************** * **** { **************************** amount ******** ******* ********** * *** ** method ******* the ******* ******* ****** ****** getBalance() * return ************ }  ****** ****** ********* * return name; }  public **** ************** name) * thisname = ***** }}Account **** ******** *** *** ***************** Inputting and ********** ************** ******* with ******* ************* ************************ ***** AccountTest { ****** ****** **** ************* ***** *** ******* ******** = new Account("Jane ****** ****** ******* account2 * *** Account("John Blue" -753);  ** display ******* balance ** each object Systemoutprintf("%s balance: ******* ***************** ********************** ******************* balance: ********* account2getName() account2getBalance());  // ****** a ******* ** ****** ***** **** *** command window ******* input * *** ******************** ********************* ******* amount *** ********* *** ** ****** double depositAmount * ****************** ** obtain **** input Systemoutprintf("%nadding ** ******** ************ *************** ******************************* // add to ************ ********* // ******* ******** ******************* ******** ******* ***************** ********************** ******************* ******** ********* account2getName() ************************ Systemoutprint("Enter ******* amount *** ********* *** ** ****** ************* = ****************** ** obtain **** input ************************* to ******** ************ depositAmount); ******************************* // *** to account2 ********* ** ******* ******** ******************* ******** ******* ***************** ********************** ******************* ******** ********* ***************** ************************ // ********* ****** **** ******* Systemoutprint("Enter ****** ** be ********* for ********* "); ** ****** ****** *************** * inputnextDouble(); ** obtain user ***** account1withdraw(withdrawAmount1);// ******* ********* **** Account1's  ** ******* balances ******************* balance: ******* account1getName() account1getBalance()); ******************* ******** $%2f%n%n" ***************** ************************ // ********* amount **** balance ********************* ****** ** ** ********* *** ********* "); // prompt double *************** * inputnextDouble(); ** ****** user ***** ************************************ ******* withdrawn **** ************ ** display ******** ******************* ******** $%2f%n" account1getName() account1getBalance()); ******************* ******** ********* ***************** ************************ } // *** ***** // end ***** *************** * *** ******** ****** ****** * class ****** ******* **** * ******** ***** ***** *** ** ********* ** ******* *** ** item sold ** *** ***** An ******* ****** ******* **** ****** ** *********** as ******** ************* **** ****** (type String) * part description (type ******* * quantity of *** **** being ********* ***** **** *** * ***** *** **** ******** Your ***** should have * constructor **** *********** *** **** ******** ********* ******* a set *** * *** ****** *** **** instance variable In addition ******* * method named **************** **** ********** *** ******* ****** (ie ********** *** ******** ** the ***** *** ***** **** ******* *** ****** ** * double value If *** ******** ** not positive ** should ** *** ** ** the price *** item ** not ******** ** ****** ** *** ** ***** * **** *** ***** InvoiceTest that ************ ***** Invoice’s capabilitiesSolution:Invoice Class ******* ***** ******* *** ******* ****** partNum; ******* ****** **************** ******* int ************* ******* double pricePerItem;  public Invoice(String ******* String ****************** ************ ****** ************* * *********** = ******** thispartDescription * **************** **************** * ************* thispricePerItem = pricePerItem; *** ****** ****** getInvoiceAmount() *** ** ***************** < ** * ****** 00; * **** ** (thisitemQuantity **** ** * ****** ** * **** * ****** **************** * ***************** * *** public String *************** * ****** ******** }  ****** void ******************** ******** * *********** * ******** }  public String ******************** * ****** partDescription; }  ****** void ************************* **************** { ******************* * **************** *** public *** ******************* * ****** ************* *** public void ********************* itemQuantity) * **************** = ************* *** ****** ****** ***************** { ****** ************* *** ****** **** ********************** ************* * thispricePerItem * ************* } }Invoice **** **************** class *********** *** ****** ****** **** ************* ***** * ** **** ************** ****** **** ******* ******** * *** ************* ****** *** *** ** ******* ******** * *** ************* ******** **** *** ); ******* ******** * new Invoice("IN3" ********** 200 -500 );  ********* ******* ****** ************************* * : \nPart ****** * "+ invoice1getPartNumber() + ******* *********** * ** ***************************** *********** ********* : "+ invoice1getQuantityOfItem()+ ******** Per **** * ** ************************* * "\nTotal Cost : * * **************************** *************************** * * \nPart ****** * "+ *********************** + "\nPart *********** * ** ***************************** *********** Purchased * ** **************************** ******** *** **** * ** ************************* * ******** **** * " * invoice2getInvoiceAmount()); *************************** * * \nPart ****** * ** invoice3getPartNumber() * ******* *********** * "+ ***************************** *********** ********* * "+ invoice3getQuantityOfItem()+ ******** *** **** * "+ ************************* + ******** **** * " * invoice3getInvoiceAmount()); ****** * *** (Employee ****** ****** * ***** called ******** **** includes ***** ******** variables—a ***** name ***** String) * last name ***** String) and * monthly ****** ******** ******* * constructor **** *********** *** three ******** variables ******* * set and * *** ****** *** each ******** ******** ** the monthly ****** ** not positive ** *** set its ***** Write a **** *** ***** ************ that ************ ***** Employee’s ************ ****** two Employee ******* and display **** ********** ****** ****** **** give **** ******** a *** ***** *** ******* **** Employee’s ****** ****** ********************** ***** ******* ***** ******** *** ******* ****** firstName; ******* ****** ********* private ****** **************** ****** *************** ********* ****** ******** ****** ************** * thisfirstName = ********** ************ * ********* if (monthlySalary > ** * ***************** * monthlySalary; * *** public ****** ************** * ****** firstName; *** ****** **** setFirstName(String ********** * ************* * ********** *** ****** String getLastName() * ****** lastName; *** public **** setLastName(String lastName) * ************ * lastName; *** public double ****************** { ****** ************** *** ****** **** *********************** ************** * **************** **** 0) * ***************** * ************** * ************ Test ************ ***** ************ *** ****** ****** void main(String[] ***** * ** TODO ************** method ****** ******** ********* = *** Employee("Nick" ******* 300); Employee employee2 * *** ****************** "Ben" ******** ** ******* Detail ********************* + *********************** * * * + employee1getLastName() * " ****** ****** ** * (12 * ****************************** ********************* * *********************** * " * * ********************** + " ****** Salary ** * *** * ******************************** // ****** hike *** *** ****** ****** ****************** * *************************** + *************************** * *** ************************************************ ****** incrementedSalary2 * employee2getMonthlySalary()+ *************************** * *** ************************************************ ** ******* ****** ********************* + *********************** * " * + ********************** + * ****** Salary :" * *** * ****************************** ********************* + employee2getFirstName() + * * * ********************** * " ****** ****** ** * *** * ****************************** **

or Buy custom answer
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question