Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Help in Java! Use the array of Student references we went over in lecture to hel

ID: 3860761 • Letter: H

Question

Help in Java!

Use the array of Student references we went over in lecture to help.   Write an Invoice class. The fields for the Invoice class for this lab are:   
String invoiceID   String description   double amount     boolean isPaid    

The Invoice class you wrote had two constructor methods, a toString( ) method, a compareTo( ) method and an equals( ) method, in addition to the methods set( ) methods for isPaid and amount.

Be sure this Invoice class has all of these methods. Create a Driver that has main( ). In main( ) create an array of ten Invoice references reading the data from a file stored in the same directory as your project. The data file is a comma delimited file named invoicedata.txt
Use a loop to create the ten Invoice objects and store their addresses in the array.   Then, write a separate loop to print the Invoices using the toString( ) method of the Invoice class.   The driver then must compare the first Invoice instance to the last Invoice object to determine which has a higher amount due. Then determine if the second and fifth Invoice objects are equal, based on the invoice id using the equals( ) method of the Invoice class.
-----------------------------------------------------------------------

invoicedata.txt. :

12323A,repair leaking faucet,23.56,false

14532E,install garbage disposal,398.40,true

34234F,snake tub,89.80,false

43543G,re-route pipe under sink,189.90,true

212343A,install ice maker,235.25,false

323243G,install new water heater,654.50,false

43434F,washing machine hook-up,135.00,true

32354F,fix outside water spout,125.00,true

12123D,new shower head,23.56,false

234354E,fix tub stopper,35.80,true

Explanation / Answer

Output :

Print the Invoices using toString()

Invoice{invoiceID='12323A', description='repair leaking faucet', amount=23.56, isPaid=false}
Invoice{invoiceID='14532E', description='install garbage disposal', amount=398.4, isPaid=true}
Invoice{invoiceID='34234F', description='snake tub', amount=89.8, isPaid=false}
Invoice{invoiceID='43543G', description='re-route pipe under sink', amount=189.9, isPaid=true}
Invoice{invoiceID='212343A', description='install ice maker', amount=235.25, isPaid=false}
Invoice{invoiceID='323243G', description='install new water heater', amount=654.5, isPaid=false}
Invoice{invoiceID='43434F', description='washing machine hook-up', amount=135.0, isPaid=true}
Invoice{invoiceID='32354F', description='fix outside water spout', amount=125.0, isPaid=true}
Invoice{invoiceID='12123D', description='new shower head', amount=23.56, isPaid=false}
Invoice{invoiceID='234354E', description='fix tub stopper', amount=35.8, isPaid=true}

Comparing the first Invoice instance to the last Invoice object to determine which has a higher amount due : first Invoice instance amount is smaller to last Invoice amount

Determine if the second and fifth Invoice objects are equal, based on the invoice id : Second Invoice instance is not eqaul to fifth Invoice amount based on the invoice id

Please let me know if you have any concern.