Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package exam2;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner console = new Scanner (System.in);
- int m = Integer.parseInt(console.nextLine());
- int n = Integer.parseInt(console.nextLine());
- int l = Integer.parseInt(console.nextLine());
- int special = Integer.parseInt(console.nextLine());
- int control = Integer.parseInt(console.nextLine());
- int number = m*100 + n*10 + l;
- for (number = m*100 + n*10 + l; number >= 111; number--) {
- if (number % 3 == 0) {
- special += 5;
- } else if (number % 10 == 5) {
- special -=2;
- } else if (number % 2 == 0) {
- special *= 2;
- }
- if (special >= control ) {
- break;
- }
- }
- if (special > control) {
- System.out.printf("Yes! Control number was reached! Current special number is %d.",special);
- } else {
- System.out.printf("No! %d is the last reached special number.",special);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement