Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Advanced Database Systems

Authors: Carlo Zaniolo, Stefano Ceri, Christos Faloutsos, Richard T. Snodgrass, V.S. Subrahmanian, Roberto Zicari

1st Edition

155860443X, 978-1558604438

More Books

Students also viewed these Databases questions

Question

1. Describe quantitative research and its assumptions.

Answered: 1 week ago