Assignment #12
Display customer information
Due Date: Monday of Week 5
30 points
This project requires a custom exception that's thrown if the customer the user requests isn't found. A CustomerIO class that contains a method that simulates retrieving a customer is provided. This is a manageable project for working with custom exceptions.
Console
Operation
- This application displays customer information for customers selected by the user. The application prompts the user to enter a customer number. If a customer with that number exists, the application displays the customer's name and address. If no customer with that number exists, the application displays the message "The customer number does not exist." Either way, the application then asks if the user wants to display another customer.
Specifications
- Create a class named Customer that stores name, address, city, state, and zipCode as public fields. The class should have a method named getNameAndAddress that returns the name and address information formatted as shown in the console output above.
- To get the information for a customer, use the CustomerIO class that's provided. This class contains a method named getCustomer that accepts a customer number (an int value) and returns a Customer object.
Enhancements
- Provide a constructor for the Customer class that accepts a customer number as a parameter and then attempts to create a Customer object using the data for that customer. Then, handle NoSuchCustomerException in the constructor of the Customer class. The constructor should throw the NoSuchCustomerException if an invalid customer number is passed to it.
- Same as the first enhancement, but have the constructor throw a different exception named CouldNotCreateCustomerException if it can't create the customer. Then, it should chain the original NoSuchCustomerException in the CouldNotCreateCustomerException.
- Enhance the getCustomer method so that it also throws IOException. To simulate the random nature of IOExceptions, have your students code the class so that IOException is thrown randomly, with a 10% chance of the exception being thrown.
- Name of program
- Programmer's name
- 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:I cannot grade if I don't get the files and receive your email.