Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class p06_numbergenerator {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int m = Integer.parseInt(scanner.nextLine());
- int n = Integer.parseInt(scanner.nextLine());
- int l = Integer.parseInt(scanner.nextLine());
- int special = Integer.parseInt(scanner.nextLine());
- int control = Integer.parseInt(scanner.nextLine());
- boolean nextline = false;
- boolean specialreached = false;
- int number = m*100+n*10+l;
- for (int i = number; i >= 111; i--) {
- if (i % 3 == 0 && !nextline) {
- special += 5;
- nextline = true;
- } else if (i % 10 == 5 && !nextline) {
- special -= 2;
- nextline = true;
- } else if (i % 2 == 0 && !nextline) {
- special *= 2;
- nextline = true;
- }
- nextline = false;
- if (special >= control) {
- specialreached = true;
- break;
- }
- }
- if(specialreached){
- 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