Create a class called Invoice that a hardware storemight use to represent an invoice for an item sold at thestore. An Invoice should include four pieces of informationas instance variables—a part number (type String), a partdescription (type String), a quantity of the item beingpurchased (type int) and a price per item (double). Your classshould have a constructor that initializes the four instancevariables. Provide a set anda get method for each instance variable. Inaddition, provide a method named getInvoiceAmount thatcalculates the invoice amount (i.e., multiplies the quantity by theprice per item), then returns the amount asa double value. If the quantity is not positive, itshould be set to 0. If the price per item is not positive, itshould be set to 0.0. Write a test appnamed InvoiceTest that demonstrates class Invoice’scapabilities.
Output should look like this
account 1 balance: $50.00 account 2 balance: $0.00 Enter withdrawal amount for account 1:20 subtracting 20.00 from account 1 balance account 1 balance: $30.00 account 2 balance: $0.00 Enter withdrawal amount for account 2:10 subtracting 10.00 from account 2 balance Debit amount exceeded account balance. account 1 balance: \$30.00 account 2 balance: \$0.00
Create a class called Invoice that a hardware store might use to represent an invoice for an item sold at the store. An
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
Create a class called Invoice that a hardware store might use to represent an invoice for an item sold at the store. An
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!