Question: Exercise 2: Input Validation: Exercise 1 Revisited (10pt) In all exercises up until now, we simply assume all user inputs follow the supposed format and

 Exercise 2: Input Validation: Exercise 1 Revisited (10pt) In all exercises

Exercise 2: Input Validation: Exercise 1 Revisited (10pt) In all exercises up until now, we simply assume all user inputs follow the supposed format and will always be valid. In real software applications, we need to account for possible invalid user inputs and make sure our programs are robust enough. In this exercise, let us revisit Exercise 1 (Sales Tax Rate) and add input validation to the program you just wrote. Save the improved program in a separate file as Hw3_Ex2.java. Your program needs to do the following input validations: (i) If the user's entry for the county is NOT an integer, display an error message and terminate the program immediately; (ii) If the user's entry for the county is an integer, but not between 1 and 3, then display an error message and terminate the program immediately; (iii) If the user's entry for whether inside Atlanta is NOT an integer, display an error message and terminate the program immediately; (iv) If the user's entry for whether inside Atlanta is an integer, but not 1 or 2, then display an error message and terminate the program immediately

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!