Advertisement
Guest User

Untitled

a guest
Dec 12th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.15 KB | None | 0 0
  1. package exam2;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Main {
  6.  
  7.     public static void main(String[] args) {
  8.         Scanner console = new Scanner (System.in);
  9.         int m = Integer.parseInt(console.nextLine());
  10.         int n = Integer.parseInt(console.nextLine());
  11.         int l = Integer.parseInt(console.nextLine());
  12.         int special = Integer.parseInt(console.nextLine());
  13.         int control = Integer.parseInt(console.nextLine());
  14.  
  15.        
  16.      int number = m*100 + n*10 + l;
  17.  
  18.         for (number = m*100 + n*10 + l; number >= 111; number--) {
  19.             if (number % 3 == 0) {
  20.                 special += 5;
  21.             } else  if (number % 10 == 5) {
  22.                 special -=2;
  23.             }   else if (number % 2 == 0) {
  24.                 special *= 2;
  25.             }
  26.             if (special  >= control ) {
  27.                 break;
  28.             }
  29.  
  30.         }
  31.         if (special > control) {
  32.             System.out.printf("Yes! Control number was reached! Current special number is %d.",special);
  33.         } else {
  34.             System.out.printf("No! %d is the last reached special number.",special);
  35.         }
  36.     }
  37.  
  38.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement