Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Read in the various parts of a user's address. Determine if each address component is valid. The rules for each component are listed below. If
Read in the various parts of a user's address. Determine if each address component is valid. The rules for each component are listed below. If the user enters invalid data, output the reason to the user. If the address is valid, determine if a company can ship to them and at what speed.
Address Component Rules Examples
street
must start with a digit see provided code below
must be at least three characters long
valid: Main St
invalid: Center Ave
invalid: A
city
cannot be empty
valid: San Francisco
valid: Buffalo
invalid:
state abbreviation
must be two characters long
program should ignore capitalization
fast shipping to states: CT ME MA NH RI and VT
regular shipping to states: NY NJ PA
no shipping to any other state
suggestion: use a switch statement for the shipping speed!
valid and fast: me
valid and fast: nh
valid and slow: Pa
invalid: California
invalid: c
zip code
must be five characters long
all characters must be a digit
valid:
valid:
invalid:
invalid:
invalid: abcde
invalid: z
In order to test whether a single character is a digit, use:
Character.isDigitch; ch is type char
Note that ch must be char, it cannot be a String of length
create a java program address validator
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