Write a program that validates a sale in dollars and cents


Basic Requirements

Write a program that validates a sale in dollars and cents with a $ and a .(period). See sample output below.
LiFiUnit6Ch15.java

- Driver class should loop until "q" is entered to quit
- If enter is not "q", then create an instance of the LiFiSaleCheck object passing the entry as an argument
- If no error
o Print amount by calling:
 print numeric from LiFiSaleCheck class
 print alphabetic from LiFiSaleCheck class
- If error
o Print error message (see sample)
LiFiSaleCheck.java class

Sales object should store the sale in 2 integer instance variables, dollars and cents, and include a string variable to hold the error. This should be initialized with null.

LiFiSaleCheck Constructor:
- Receive sale as a string
- Perform error checking to ensure time was entered in proper format to include a color (.) between the dollars and cents and a $ at the start of the string.
- Use indexOf and substring to separate the sale string into the appropriate instance variables
- Use try/catch to catch format errors of dollars and cents as shown in example
- If an error occurs, change the error instance variable to reflect the error (see sample)
- If more than one error occurs in the format of the dollars and cents, show both.

print numeric method:
- Print in the format $123.45 using both dollars and cents instance variables
- Print in the format 123 dollars and 45 cents using both dollars and cents instance variables

print alphabetic method:

- Print in the format 123 dollars and 45 cents using both dollars and cents instance variables getError method:
- Include a getError method that returns the error instance variable to the print method

Solution Preview :

Prepared by a verified Expert
JAVA Programming: Write a program that validates a sale in dollars and cents
Reference No:- TGS02399967

Now Priced at $20 (50% Discount)

Recommended (95%)

Rated (4.7/5)