CIS 35A: Introduction to Java Programming

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

Lab #8 (Exercise 9-4)

Create and use an enumeration

Due Date: Tuesday of Week 3
10 points

In this lab, you'll create an enumeration and then use it in a test application.

  1. create an enumeration named CustomerType, and save it. This enumeration should contain constants that represent three types of customers: retail, trade, and college.

  2. Open the CustomerTypeApp class. Then, add a method to this class that returns a discount percent (0.10 for retail, 0.30 for trade, and 0.20 for college) depending on the CustomerType variable that's passed to it.

  3. Add a statement to the main method that displays the string returned by the toString method of the customer type. Then, compile and run the application again to see the result of this method.

  4. Add toString method to CustomerType enumeration. This method should return a string that contains "Retail customer," "Trade customer," or 'College customer" depending on the customer type. Compile this class, then run the CustomerType class again to view the results of the toString method.
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.

When you are ready, upload the java program by clicking the link below:

Upload Lab

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