Question: The complete bar code consists of a start full frame bar, the 9 digit barcodes, a check digit barcode, and a stop full frame bar.

The complete bar code consists of a start full frame bar, the 9 digit barcodes, a check digit barcode, and a stop full frame bar.

The check digit is computed as follows:

1) Add all nine digits and compute the remainder of the sum when divided by 10.

2) If the remainder is zero, the check digit is zero.

3) Otherwise, the check digit is ten minus the remainder.

You can use the following data declarations to encode the barcode for each digit.

public static final char FB='\u2503',HB='\u257b'; private static String[] barcode = { ""+FB+FB+HB+HB+HB, ""+HB+HB+HB+FB+FB, ""+HB+HB+FB+HB+FB, ""+HB+HB+FB+FB+HB, ""+HB+FB+HB+HB+FB, ""+HB+FB+HB+FB+HB, ""+HB+FB+FB+HB+HB, ""+FB+HB+HB+HB+FB, ""+FB+HB+HB+FB+HB, ""+FB+HB+FB+HB+HB};

FB is a unicode full bar and HB is a unicode half bar. barcode[digit] is the barcode for that digit.

Make a class Postnet with a constructor that takes a 9-digit zip+4 code and a method public String barCode() that returns the barcode for that zip+4. Write a test program to ask the user for a zip+4 code and then print the corresponding bar code.

My code:

import java.util.Scanner;

public class Postnet {

private int i;

public static final char FB = '\u2503', HB = '\u257b'; private static String[] barcode = { "" + FB + FB + HB + HB + HB, "" + HB + HB + HB + FB + FB, "" + HB + HB + FB + HB + FB, "" + HB + HB + FB + FB + HB, "" + HB + FB + HB + HB + FB, "" + HB + FB + HB + FB + HB, "" + HB + FB + FB + HB + HB, "" + FB + HB + HB + HB + FB, "" + FB + HB + HB + FB + HB, "" + FB + HB + FB + HB + HB};

public Postnet(int i) {

this.i = i;

}

public String barCode(int i) {

return i;

} public static void main(String[] args){

Scanner sc = new Scanner(System.in);

Postnet pn = new Postnet();

System.out.println(pn.barCode); } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!