Check06B - output.print("POSTNET Code:...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
import java.io.PrintStream; import java.util.Scanner; i public class Check06B { public static void main(String[] args) { PrintStream output = System.out; output.print("Enter a string of digits: "); Scanner input = new Scanner(System.in); String digits = input.nextLine(); int checkDigit = 0; final String SOURCE = "||::: :::|| ::|:| ::||: :|::| :|:|: :||:: |:::| |::|: |:|::"; String numbers[] = SOURCE.split(" ");
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: output.print("POSTNET Code: |"); for (int index = 0; index < digits.length(); index++) { String character = String.valueOf(digits.charAt(index)); output.print(numbers[Integer.parseInt(character)]); checkDigit += Integer.parseInt(character); } final int TEN = 10; checkDigit = (checkDigit % TEN != 0) ? TEN - checkDigit % TEN : 0; output.println(numbers[checkDigit] + "|"); } }...
View Full Document

This note was uploaded on 09/16/2011 for the course CSE CSE 1020 taught by Professor Burton,ma during the Fall '10 term at York University.

Ask a homework question - tutors are online