Question
Implement the following requirements: Create an Invoice class with three fields: ID number , balance due and day due . The constructor for Invoice will
Implement the following requirements:
Create an Invoice class with three fields: ID number, balance due and day due.
The constructor for Invoice will accept three arguments for the three fields noted above.
In the Invoice class constructor check that the id number falls within a constant range where the low id number is 100 and the high id number is 999. Check that the day falls within aconstant range where the low day number is 1 and the high day is 31. If the ID number or the day fall outside of the specified ranges, throw an argument exception. Assign the values passed in to the corresponding class variables.
Create read-only implemented accessors for ID number, balance due, and day due.
In Main instantiate an array of five (5) Invoice objects.
Create a constant integer and set the default constant to 999.
Prompt the user for inputs for ID number, balance, and day. For the inputs, use if statements to verify that each input for each of the three fields is the required value type (int, double, and day). If the input being checked is not the correct value type set the field equal to the default constant.
Handle any exceptions (try-catch block) that are thrown when the object is instantiated. Trythe assignment of each instantiation object, passing the three entered values to the object array element and catchan argument exception, assigning an instantiation using the constant default value, 0, and 1for the ID number, balance, and day respectively.
At the end of input display all the entered and possibly corrected records as shown below.
Internal documentation.
The following is an example of possible output:
Enter invoice number >> 100 Enter balance >> 1000.00 Enter due day >> 15 Enter invoice number >> 1000 Enter balance >> 2000.00 Enter due day >> 16 Enter invoice number >> 300 Enter balance >> 3000.00 Enter due day >> 40 Enter invoice number >> xyz Enter balance >> 4000.00 Enter due day >> 17 Enter invoice number >> 500 Enter balance >> 5000.00 Enter due day >> 18 Entered invoices #100 $1,000.00 day 15 #999 $0.00 day 1 #999 $0.00 day 1 #999 $0.00 day 1 #500 $5,000.00 day 18 Press any key to continue . . .
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started