Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program that prompts the user for a postal code and then determines if it is valid or not. To be valid the postal

Write a program that prompts the user for a postal code and then determines if it is valid or not. To be valid the postal code must have exactly 7 characters, in the format of X#X #X#, where X is a letter and # is a number, with a space in the middle. Your program must first verify if the input has 7 characters if no then the program will immediately conclude that The postal code is not valid; if yes then it will further determine if the input matches the X#X #X# format and then make the decision whether the input is valid or not. You are encouraged to try to minimize the unnecessary steps the program must go through after an input is determined as invalid. Rewrite the program you created to answer the second question of lab 5 to implement the following change: when report The postal code is not valid your program must point out where the problem is either the length of the postal code is not correct (if it doesnt contain 7 characters) or character X is not right, where X is an integer in the range of 1 to 7, which is the position of the character that your program first finds problem in the postal code. This should be a java program.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions