$29
Implement a solution to the problem described below. Your work must include the following:
• Your version of the PostalCode.java
◦ include as many comments as are necessary to describe what the given code segment is doing
◦ make sure that your code is formatted properly
• Output of your program that shows multiple runs that test various scenarios
• Please make sure to include your name in each file that you are submitting
BEFORE STARTING PLEASE READ THE PROBLEM DESCRIPTION AND THE INSTRUCTIONS CAREFULLY.
Problem Description
For faster sorting of letters, the United States Postal Service encourages companies that send large volumes of mail to use a bar code denoting the ZIP code. The zip code is encoded in half-height bars and full-height bars using encoding shown in the following table:
The barcode starts with a full-height bar followed by the encoded postal code digits, followed by a check digit, followed by full-height bar.
Each individual digit is represented by a set of five bars, two of which are full bars (as shown in the table above).
The check digit is computed as follows: add up all digits, and choose the check digit to make the sum a multiple of 10. For example, the sum of the digits in the ZIP code 55555-1237 is 38, so the check digit is 2 to make the sum equal to 40 (multiple of 10).
Together with the initial and terminal frame bars, 5555512372 barcode would be represented as:
Your Task
Write a program that asks the user for a nine-digit ZIP code in the form DDDDD-DDDD (for example 95014-5143) and prints the bar code. Use ‘:’ for half bars, and ‘|’ for full bars.
For example, 95014-5143 becomes
||:|:::|:|:||::::::||:|::|:|:|::::||:|::|::||:|::|:|
where last five bars represent the check digit. Note that the ‘-‘ is ignored.
The program validates the input. After converting the valid zip code to its barcode representation, asks the user if (s)he wants to convert another one.
Please note that the finished client and the skeleton of the service class have been provided so your task is to finish the service class as per given UML diagram.
Sample Run of the program
Enter a ZIP code in the form DDDDD-DDDD
abcd
Your input is invalid, please re-enter
Enter a ZIP code in the form DDDDD-DDDD
123-456
Your input is invalid, please re-enter
Enter a ZIP code in the form DDDDD-DDDD
12345678
Your input is invalid, please re-enter
Enter a ZIP code in the form DDDDD-DDDD
12345-5678
.....The zip string to be processed is 123455678
.....The checksum is 41
.....The zip with the check digit is 1234556789
The zip code: 12345-5678 has the following bar code: |:::||::|:|::||::|::|:|:|::|:|::||::|:::||::|:|:|::|
Would you like to generate another bar code?
yes
Enter a ZIP code in the form DDDDD-DDDD
95014-5143
.....The zip string to be processed is 950145143
.....The checksum is 32
.....The zip with the check digit is 9501451438
The zip code: 95014-5143 has the following bar code: ||:|:::|:|:||::::::||:|::|:|:|::::||:|::|::||:|::|:|
Would you like to generate another bar code?
yes
Enter a ZIP code in the form DDDDD-DDDD
93012-1211
.....The zip string to be processed is 930121211
.....The checksum is 20
.....The zip with the check digit is 9301212110
The zip code: 93012-1211 has the following bar code: ||:|::::||:||::::::||::|:|:::||::|:|:::||:::||||:::|
Would you like to generate another bar code?
No
Goodbye!
UML Diagram