The Artima Developer Community
Sponsored Link

Java Answers Forum
Arrays & Methods

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Becky Gatang'i

Posts: 2
Nickname: bex
Registered: Nov, 2005

Arrays & Methods Posted: Nov 1, 2005 10:28 AM
Reply to this message Reply
Advertisement
Please help me solve this question:

ADDRESSES AND ZIP CODES
The BotswanaPost has decided to automate their mail sorting activity. They have
decided to adopt the zip code method of sorting. A zip code is a 5 digit number
(equivalent to a private bag/p.o. box number) that specifies the destination of a
mail article (letter/ parcel). They have instituted that companies sending bulk
mail must use a barcode denoting the zip code.
The encoding scheme for a five five ­digit ZIP code are followed by a correction
digit, which is computed as follows: Add up all digits, and choose the correction
digit to make the sum a multiple of 10. For example, the ZIP code 95014 has sum
of digits 19, so the correction digit is 1 to make the sum equal to 20.
Each digit of the ZIP code, and the correction digit, is encoded according to the
following table:
1: 0 0 0 1 1
2: 0 0 1 0 1
3: 0 0 1 1 0
4: 0 1 0 0 1
5: 0 1 0 1 0
6: 0 1 1 0 0
7: 1 0 0 0 1
8: 1 0 0 1 0
9: 1 0 1 0 0
0: 1 1 0 0 0
where 0 denotes a half bar and 1 a full bar. Note that they represent all
combinations of two full and three half bars.
Write a Java program that reads addresses from a file called “address.dat ” and
writes out the addresses to a file called “zip.dat ” with the zip code replaced by the
bar code. Use “!” for full bars and “:” for half bars. For example 95014 becomes
(950141):
!:!:: :!:!: !!::: :::!! :!::! :::!!

Each line in the file is of the form: lastname firstname city zipCode .
For example,
Nkgau Tallman Molepolole 95014

For the above line, your program should write the output to the file as follows:

Tallman Nkgau
Molepolole
!:!:: :!:!: !!::: :::!! :!::! :::!!

You MUST use the following program structure:
• Use a method to encode the zip code. It takes in a 5 ­digit number and returns a
6 ­digit number after adding the correction digit.
• Use a method to take in a 6 ­digit number representing a zip code followed by
the correction digit and returns a string representing the bar code. You MUST use
a Boolean method to verify that the 6 ­digit number indeed represents a zip code.
You MUST also use a method that takes in a digit and returns a string
representing the encoding of that digit as given in the above table.

Topic: "for loop : problem in batch file Previous Topic   Next Topic Topic: regarding my query on tracking the selected checkbox values across the pagi

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use