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

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

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

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

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 user’s 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)


□ 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

Expert Answer


Note:- Changed the main method to include a flag that will be checked in while condition.

import java.util.*;
import java.lang.String;

public class barcode {
public static String [] bars = {“||:::”,”:::||”, “::|:|”, “::||:”, “:|::|”, “:|:|:”, “:||::”,”|:::|”, “|::|:”, “|:|::” };

public static int find_digit(String str) {
case “||:::”:
return 0;
case “:::||”:
return 1;
case “::|:|”:
return 2;
case “::||:”:
return 3;
case “:|::|”:
return 4;
case “:|:|:”:
return 5;
case “:||::”:
return 6;
case “|:::|”:
return 7;
case “|::|:”:
return 8;
case “|:|::”:
return 9;
return -1;

public static void ConvertBar(int ss)
if(ss<10000 || ss>99999)
System.out.println(“Zip Code does not exist”);
StringBuffer barC = new StringBuffer(“|”);
int rev =0;
while (ss != 0)
rev = rev*10 + ss % 10;
ss /= 10;
int total = 0;
total = total+(rev%10);
System.out.println(“Zip Code does not exist”);
System.out.print(“This zipcode is equivalant to: “);

public static void ConvertZip(String ss1)
int zip = 0;
int n = ss1.length();
System.out.println(“Zip Code does not exist”);
int cnt=0;
for(int i=1;cnt<5;i+=5,cnt++)
zip = zip*10;
int x = find_digit(ss1.substring(i,i+5));
System.out.println(“Zip Code does not exist”);
zip = zip + x;
System.out.print(“Corresponding Zipcode : “);
public static void main(String[] args) {
int flag=1; //add a flag to check whether the user has selected exit option
System.out.println(“Press 0 to convert zipcode to barcode”);
System.out.println(“Press 1 to convert barcode to zipcode”);
System.out.println(“Press 2 to exit”);
Scanner s =new Scanner(;
int c = s.nextInt();
case 0:
Scanner s2 =new Scanner(;
System.out.println(“Enter Zipcode”);
int ss = s2.nextInt();
case 1:
Scanner s3 =new Scanner(;
System.out.println(“Enter Barcode”);
String ss1 = s3.nextLine();
case 2:
Scanner s4 =new Scanner(;
int ss2 = s4.nextInt();

System.out.println(“Not available!!”);


Buy Essay
Calculate your paper price
Pages (550 words)
Approximate price: -

Help Me Write My Essay - Reasons:

Best Online Essay Writing Service

We strive to give our customers the best online essay writing experience. We Make sure essays are submitted on time and all the instructions are followed.

Our Writers are Experienced and Professional

Our essay writing service is founded on professional writers who are on stand by to help you any time.

Free Revision Fo all Essays

Sometimes you may require our writers to add on a point to make your essay as customised as possible, we will give you unlimited times to do this. And we will do it for free.

Timely Essay(s)

We understand the frustrations that comes with late essays and our writers are extra careful to not violate this term. Our support team is always engauging our writers to help you have your essay ahead of time.

Customised Essays &100% Confidential

Our Online writing Service has zero torelance for plagiarised papers. We have plagiarism checking tool that generate plagiarism reports just to make sure you are satisfied.

24/7 Customer Support

Our agents are ready to help you around the clock. Please feel free to reach out and enquire about anything.

Try it now!

Calculate the price of your order

Total price:

How it works?

Follow these simple steps to get your paper done

Place your order

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.


Let us write that nagging essay.


Submit Your Essay/Homework Instructions

By clicking on the "PLACE ORDER" button, tell us your requires. Be precise for an accurate customised essay. You may also upload any reading materials where applicable.


Pick A & Writer

Our ordering form will provide you with a list of writers and their feedbacks. At step 2, its time select a writer. Our online agents are on stand by to help you just in case.


Editing (OUR PART)

At this stage, our editor will go through your essay and make sure your writer did meet all the instructions.


Receive your Paper

After Editing, your paper will be sent to you via email.