Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Program is in Java [60pts] Write a Java application/program to prompt user to enter a zip code. The application will validate the inputted zip code

Program is in Java

image text in transcribed

image text in transcribed

[60pts] Write a Java application/program to prompt user to enter a zip code. The application will validate the inputted zip code is a 5 digits number or not. If not, then the application will print a message says invalid zip code, and then ask user to re-enter a zip code until the user entered a valid zip code or enters " q " (means quit). - Open "ZipCodeValidation.java" (download from here: ZipCodeValidation.java ) - Add your name in the comment at the beginning of the java program. - Add validation part in the program: the inputted zip code must be five characters long, and each character should be a digit (0-9). - If user inputted zip code is valid (e.g., 01134), then print out a message in console to tell user the validation result. - If user inputted zip code is invalid (e.g., 1234, rrt45), then the application will print a message in console to tell user the validation result, and then ask user to re-enter a zip code until the user entered a valid zip code or enters " q " (means quit). (Hint: implement a loop here) Bonus points (10 points): Instead of read in user input from console, the application will generate a simple GUI input box to let user enter zip code, and generate a simple message box to tell whether the zip code is valid or not. (See examples in Lecture 2.1 and Lecture 2.2) - [40pts] Test and debug your program to make sure there is no errors. Create a testing report to include at least two testing cases and testing result (you may copy the program input and output part, or use screenshots, save your testing result as a word (.docx) or PDF (.pdf) file named "w2LabTestingReport". public class zipCodeValidation \{ public static void main(String[] args) \{ // Use JOptionPane class to create an input dialog box for user input zip code String userInput = JoptionPane.showInputDialog("Enter a zip code; we will validate it for you."); boolean validInput = false; // Use a loop to have the user re-enter the zip code until the entered code is valid, or enter q/Q to quit \}// Print out validation result for each user inputted zip code in loop

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions