Advertisement
veronikaaa86

06. Barcode Generator

Aug 14th, 2021
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. package examPreparation;
  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. //2345
  10. //6789
  11. int firstNum = Integer.parseInt(scanner.nextLine());
  12. int secondNum = Integer.parseInt(scanner.nextLine());
  13.  
  14. //firstNum
  15. int digitFirstOne = firstNum / 1000;
  16. int digitFirstTwo = firstNum / 100 % 10;
  17. int digitFirstThree = firstNum / 10 % 10;
  18. int digitFirstFour = firstNum % 10;
  19.  
  20. //secondNum
  21. int digitSecondOne = secondNum / 1000;
  22. int digitSecondTwo = secondNum / 100 % 10;
  23. int digitSecondThree = secondNum / 10 % 10;
  24. int digitSecondFour = secondNum % 10;
  25.  
  26. for (int first = digitFirstOne; first <= digitSecondOne; first++) {
  27. for (int second = digitFirstTwo; second <= digitSecondTwo; second++) {
  28. for (int third = digitFirstThree; third <= digitSecondThree; third++) {
  29. for (int fourth = digitFirstFour; fourth <= digitSecondFour; fourth++) {
  30. boolean firstOdd = first % 2 != 0;
  31. boolean secondOdd = second % 2 != 0;
  32. boolean thirdOdd = third % 2 != 0;
  33. boolean fourthOdd = fourth % 2 != 0;
  34.  
  35. if (firstOdd && secondOdd && thirdOdd && fourthOdd) {
  36. System.out.printf("%d%d%d%d ", first, second, third, fourth);
  37. }
  38. }
  39. }
  40. }
  41. }
  42. }
  43. }
  44.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement