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

Create and use an enumeration ; exercise 10-4 from java programming murach books

ID: 3558031 • Letter: C

Question

Create and use an enumeration ; exercise 10-4 from java programming murach books(308 page), 4th edition, I don't know how to finish that code, thanks for ur help!!

In this exercise, you'll create an enumeration and then use it in a test application. Open the project named ch10_ex4_Enumeration that's in the ex _starts directory. Create an enumeration named Customer Type. This enumeration should contain constants that represent three types of customers: retail, trade, and college. Open the Customer Type App class. Then, add a method to this class that returns a discount percent (.10 for retail, .30 for trade, and .20 for college) depending on the Customer Type variable that's passed to it. Add code to the main method that declares a Customer Type variable, assigns one of the customer types to it, gets the discount percent for that customer type, and displays the discount percent. Run the application to be sure that it works correctly. Add a statement to the main method that displays the string returned by the to String method of the customer type. Then, run the application again to see the result of this method. Add a to String method to the Customer Type enumeration. This method should return a string that contains "Retail customer," "Trade customer," or "College customer" depending on the customer type. Run the application one more time to view the results of the to String method.

Explanation / Answer

here is your result.

i dont know about the project in statement 1.

But i have created the solution accordingly.

save the file with Customer.java and run

enum CustomerType
{
   retail(1),
   trade(3),
   college(2);
   private int value;
   private CustomerType(int val)
   {
       this.value = val;
   }
   public int getValue(){
   return value;
   }
   public String toString()
   {
       String result = new String();
       switch(this)
       {
           case retail:
           result = "Retail Customer";
           break;
           case trade:
           result = "Trade Customer";
           break;
           case college:
           result = "College Customer";
           break;
       }
       return result;
   }
}
class CustomerTypeApp
{
   public int getDiscount(int cust)
   {
       return cust * 10;
   }
}
public class Customer
{
   public static void main(String[] args)
   {
       CustomerTypeApp cust = new CustomerTypeApp();
       CustomerType custType = CustomerType.retail;
       System.out.println("Discount percent is:"+cust.getDiscount(custType.getValue()));
       System.out.println("Customer Type:"+custType);
   }
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote