Advertisement
Guest User

Untitled

a guest
Aug 15th, 2018
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. package Exams;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class numberGenerator {
  6. public static void main(String[] args){
  7. Scanner scanner = new Scanner(System.in);
  8.  
  9. int m = Integer.parseInt(scanner.nextLine());
  10. int n = Integer.parseInt(scanner.nextLine());
  11. int l = Integer.parseInt(scanner.nextLine());
  12. int specNum = Integer.parseInt(scanner.nextLine());
  13. int otherNum = Integer.parseInt(scanner.nextLine());
  14.  
  15. boolean isTrue = false;
  16. int specNum2 = specNum;
  17. int sum = 0;
  18. for(int i = m; i >= 1; i--){
  19. for(int c = n; c >= 1; c--){
  20. for(int z = l; z >= 1; z--){
  21. sum = i * 100 + c * 10 + z;
  22. if(sum % 3 == 0){
  23. specNum2 += 5;
  24. }else if( sum % 5 == 0 ){
  25. specNum2 -= 2;
  26. }else if(sum % 2 == 0){
  27. specNum2 *= 2;
  28. }
  29.  
  30. if(specNum2 >= otherNum){
  31. System.out.printf("Yes! Control number was reached! Current special number is %d.",specNum2);
  32.  
  33. return;
  34. }
  35. }
  36. }
  37. }
  38.  
  39. System.out.printf("No! %d is the last reached special number.",specNum2);
  40.  
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement