Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Programming Project P8.6 in Big Java . This time I have provided a single template only, ZipTest.java. Your code must work with the ZipTest class

Programming Project P8.6 in Big Java.

This time I have provided a single template only, ZipTest.java. Your code must work with the ZipTest class I have provided.

What to hand in: In addition to the source files for your programs include a single text file named readMe.txt with an explanation of what you did for each programming problem. That is, write in plain English, instructions for using your software, explanations for how and why you chose to design your code the way you did. The readMe.txt file is also an opportunity for you to get partial credit when certain requirements of the assignment are not met. Add the readMe.txt file to the projects root directory on codio along with all of the .java files.

The test file:

//********************************* // // Zip code class // // This is a test class for your zip code class. // Your Zipcode class must work with this test class. // Do not alter this class. // //*********************************

import java.util.Scanner;

public class ZipTest{

public static void main(String[] args){ Scanner input = new Scanner(System.in);

//Convert from ZIP to bar code System.out.println("Please enter a ZIP code: "); int zip = input.nextInt(); Zipcode code1 = new Zipcode(zip); System.out.println("The corresponding bar code: "); System.out.println(code1.getBarcode());

//Convert from bar to ZIP code System.out.println("Now please provide a bar code: "); String bar = input.nextLine(); Zipcode code2 = new Zipcode(bar); System.out.println("The corresponding ZIP code: "); System.out.println(code2.getZIPcode()); } }

image text in transcribed

P8.6 For faster sorting of letters, the U.S. Postal Service encourages companies that send large volumes of mail to use a bar code denoting the ZIP code (see Figure 8) The encoding scheme for a five-digit ZIP code is shown in Figure 9. There are full-height frame bars on each side. The five encoded digits are followed by a check digit, which is computed as follows: Add up all digits, and choose the check digit to CODE C671RTS2 JOHN DOE 1009 FRANKLIN BLVD SUNNYVALE Frame bars CO57 CA 95014-5143 Digit 1 Digit 2 Digit 3 Digit 4 Digit 5 Check Figure 8 A Postal Bar Code Figure 9 Encoding for Five-Digit Bar Codes Chapter 8 Designing Classes make the sum a multiple of 10. For example, the sum of the digits in the ZIP code 95014 is 19, so the check digit is 1 to make the sum equal to 20 Each digit of the ZIP code, and the check digit, is encoded according to the table at right, where 0 denotes a half bar and 1 a full bar. Note that they represent all combinations of two full and three half bars. The digit can be computed easily from the bar code using the column weights 7, 4,2,1,0. For example, 01100 is Weight Digit 7 42 0 0 0 10 0x7+1x4+1x2+0x1+0x0-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 (Alternatively, write a graphical application that draws real bars.) Your program should also be able to carry out the opposite conversion: Translate bars into their ZIP code, reporting any errors in the input format or a mismatch of the digits

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

Database Driven Web Sites

Authors: Joline Morrison, Mike Morrison

2nd Edition

? 061906448X, 978-0619064488

More Books

Students also viewed these Databases questions

Question

What is Change Control and how does it operate?

Answered: 1 week ago

Question

How do Data Requirements relate to Functional Requirements?

Answered: 1 week ago