CIS 35A: Introduction to Java Programming

Home | Green Sheet | Lectures | Assignments | FAQ | Grades | Students

Lab #5 (Exercise 6-3)

Use objects in the Invoice application

Due Date: Wednesday of Week 2
10 points

In this lab, you'll create an Invoice class and construct objects from it as you convert the Invoice application to an object-oriented application.

  1. If you downloaded the file, open the files named InvoiceApp.java and Validator.java that are in your computer or USB drive. If you don't have the files, copy and paste the codes below:
  2. InvoiceApp class

    Validator class

  3. Start a new class named Invoice and save it in the same directory. Then, write the code for this class so it provides allof the data and all of the processing for an Invoice object. Its constructor should require the subtotal and customer type as its only paramters, and it should initialize instance variables for discount percent, discount amount, and invoice total. Its method should include the required get and set methods, plus a method named getInvoice that returns a string that contains all of the data for an invoice in a printable format. When you're done, compile the Invoice class.

  4. Modify the code in the InvoiceApp class so it creates an Invoice object and uses its getInvoice method to get the formatted data for invoice. That should simplify this class considerably. Then, compile and test this class to make sure that this application works the way it did in step 1.
Include in your program the following comments:
  • Name of program
  • Team's name with all the names of the members (e.g. Team A: John Doe, Jane Smith, etc.)
  • Current Date
  • Computer system and compiler you are using
  • Brief description of the program

Compile and run the Java program.

Take a screen capture by hitting simultaneously the keys Alt and Print Screen (Prt Sc) of the output results (console) and paste it in MS Paint. Save it as a gif file.

When you are ready, upload the java programs (Invoice, InvoiceApp and Validator) by clicking the link below:

Upload Lab

I cannot grade if I don't get the files and receive your email.