Java code that takes user input of Zipcode and turns it into a bar code This program works 100%. If someone could help me just separate it into two classes that would be really great. I have been working on it for a while and I can't seem to figure out how to make it happen. This is the full program that I have so far.

import java.util.Scanner;
public class BarCodeConverter {


public static void main(String[] args) {
    Scanner input = new Scanner(System.in); 
    System.out.print("Enter a zip code: "); 
    int zip = input.nextInt(); 
    input.close(); 
    int checkDigit = checkDigit(zip); 

    String barcode = "|"; 
    barcode = dBarCode(checkDigit) + barcode; 
    for (int i = 0; i &lt; 5; i++) { 
        barcode = dBarCode(checkDigit) + barcode; 
        zip /= 10; 
    } 
    barcode = "|" + barcode; 
    System.out.println(barcode); 


} 
 public static int checkDigit(int zip) { 
    int remaining = zip; 
    int sum = 0; 
    while (remaining &gt; 0) { 
        sum += remaining % 10; 
        remaining /= 10; 
    } 
    return 10 - (sum % 10); 
} 

public static String dBarCode(int digit) {

    if (digit == 1) { 
        return ":::||"; 
    } 
    if (digit == 2) { 
        return "::|:|"; 
    } 
    if (digit == 3) { 
        return "::||:"; 
    } 
    if (digit == 4) { 
        return ":|::|"; 
    } 
    if (digit == 5) { 
        return ":|:|:"; 
    } 
    if (digit == 6) { 
        return ":||::"; 
    } 
    if (digit == 7) { 
        return "|:::|"; 
    } 
    if (digit == 8) { 
        return "|::|:"; 
    } 
    if (digit == 9) { 
        return "|:|::"; 
    } 
    return "||:::"; 

  }

}
My two cents:

I did not know about this system, so the methods don't tell me much. checkDigit calculates some kind of validation number? Perhaps name it something like calculateCheckDigit. Same for dBarCode.

Also, you only ever call checkDigit on zip once, and then keep on calling it on the checkDigit variable, although this one never changes? Could it be a bug?

Some other comments:


Close the scanner as soon as possible; it is also AutoCloseable, so you can use try-with-resources: try-with-resources
dBarCode can be implemented with a switch statement, an array of Strings or possibly a Map.
I'd extract the zip to barcode functionality of the main method, without the input/output, to a separate function


I think it is fine to leave the functions in one class, and leave them static.