Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Exams;
- import java.util.Scanner;
- public class 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 specNum = Integer.parseInt(scanner.nextLine());
- int otherNum = Integer.parseInt(scanner.nextLine());
- boolean isTrue = false;
- int specNum2 = specNum;
- int sum = 0;
- for(int i = m; i >= 1; i--){
- for(int c = n; c >= 1; c--){
- for(int z = l; z >= 1; z--){
- sum = i * 100 + c * 10 + z;
- if(sum % 3 == 0){
- specNum2 += 5;
- }else if( sum % 5 == 0 ){
- specNum2 -= 2;
- }else if(sum % 2 == 0){
- specNum2 *= 2;
- }
- if(specNum2 >= otherNum){
- System.out.printf("Yes! Control number was reached! Current special number is %d.",specNum2);
- return;
- }
- }
- }
- }
- System.out.printf("No! %d is the last reached special number.",specNum2);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement