Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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 encoding scheme for a five-digit zip code is shown in figure 2. The five encoded digits are followed by a correction digit, which is computed as follows: Add up all the digits, and choose the correction digit to make the sum a multiple of 10. For example, the ZIP code 95014 has a sum of digits 19, so the correction digit is 1 to make the sum equal to 20

image text in transcribedFigure 2. Encoding for Five-Digit Bar Codes

Each digit of the ZIP code, and the correction digit, is encoded according to the following table:

image text in transcribed

The digit cab be easily computed from the bar code using the column weights 7, 4, 2, 1, 0. For example, 01100 is 0 x 7 + 1 x 4 + 1 x 2 + 0 x 1 + 0 x 0 = 6. The only exception is 0, which would yield 11 according to the weight formula. Write a program that asks the user for a zip code and prints the bar code. Use : for half bars, | for full bars.

For example, 95014 becomes

||:|:::|:|:||::::::||:|::|:::|||

Provide these methods: public static void printDigit(int d) //This method takes one integer digit only, and outputs its value in barcode public static void printBarCode(int zipCode) //This method takes the zipcode and prints the complete bar code You can add other methods as needed

Write the method that reads in a bar code (with : denoting half bars and | denoting full bars) and prints out the zip code it represents. Print an error message if the bar code is not correct.

Write the code with a menu asking the user to select between reading the bar code, reading the zip code be careful, the zipcode can not start with a zero, or exit the program.

When the user selects one of the first two options the user should select between entering the bar/zip code (based on the selection from the previous menu) and using a randomly generated one.

The code should repeat until the user selects to exit. Your code should validate the users entry for the menu.

Upload your documented code to BeachBoard with sample runs, and demonstrate in class. Print one page only The other file

It is important to have method calls in main, besides some important code lines.

*** Please help me with my code, this is what I have so far but I am trying to put this in a while loop so it will keep asking the user to input zip code and brcode until they hit like 2 and it stops. this is the list of things i need to change:

Repeats until user chose to exit

Validate entry

Submenu

Functions (4 points each)

public static void printDigit(int d)

public static void printBarCode(int zipCode)

Random generator usage(Could be a standalone function or not)

Valid correction digit (Could be a standalone function or not)

General

Documentation (5 points) o Comments

o General Name & Description

o For every function Output (4 points)

o Multiple based on the menu

frame bars digit 1 digit 2 digit 3 digit 4 digit 5 check digit Figure 2. Encoding for Five-Digit Bar Codes

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

Handbook Of Relational Database Design

Authors: Candace C. Fleming, Barbara Von Halle

1st Edition

0201114348, 978-0201114348

More Books

Students also viewed these Databases questions

Question

Find the derivative of y= cos cos (x + 2x)

Answered: 1 week ago