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:
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.