Advertisement
veronikaaa86

06. Barcode Generator v.02

Aug 13th, 2022
1,390
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.22 KB | None | 0 0
  1. package examPrep;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class P06BarcodeGenerator {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.         int firstNum = Integer.parseInt(scanner.nextLine());
  10.         int secondNum = Integer.parseInt(scanner.nextLine());
  11.  
  12.         //2345
  13.         //6789
  14.  
  15.         int startUnits = firstNum % 10;
  16.         int startTens = firstNum / 10 % 10;
  17.         int startHundreds = firstNum / 100 % 10;
  18.         int startThousands = firstNum / 1000 % 10;
  19.  
  20.         int endUnits = secondNum % 10;
  21.         int endTens = secondNum / 10 % 10;
  22.         int endHundreds = secondNum / 100 % 10;
  23.         int endThousands = secondNum / 1000 % 10;
  24.  
  25.         for (int i = startThousands; i <= endThousands; i++) {
  26.             for (int j = startHundreds; j <= endHundreds; j++) {
  27.                 for (int k = startTens; k <= endTens; k++) {
  28.                     for (int l = startUnits; l <= endUnits; l++) {
  29.                         if (i % 2 != 0 && j % 2 != 0 && k % 2 != 0 && l % 2 != 0) {
  30.                             System.out.printf("%d%d%d%d ", i, j, k, l);
  31.                         }
  32.                     }
  33.                 }
  34.             }
  35.         }
  36.     }
  37. }
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement