Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Scanner input = new Scanner (System.in);
- System.out.println("Welcome to the number sorter!");
- System.out.println("The first number you enter must be smaller than the second number you enter.");
- System.out.print("Please enter a number between 0-99: ");
- double fint = input.nextDouble();
- if (fint >= 0 && fint <= 99) {
- System.out.print("Now, enter another number between 0-99: ");
- double sint = input.nextDouble();
- System.out.println("Okay, so the range is between " + fint + " and " + sint + ".");
- System.out.println("Still working on it...");
- double randomNum1 = fint + (int)(Math.random() * sint);
- double randomNum2 = fint + (int)(Math.random() * sint);
- double randomNum3 = fint + (int)(Math.random() * sint);
- System.out.println("Here are your random numbers:");
- System.out.println(randomNum1);
- System.out.println(randomNum2);
- System.out.println(randomNum3);
- double rNum1 = randomNum1 % 2;
- double rNum2 = randomNum2 % 2;
- double rNum3 = randomNum3 % 2;
- System.out.println(rNum1 == 0);
- System.out.println(rNum2 == 0);
- System.out.println(rNum3 == 0);
- } else {
- System.out.println("That number is not between 0-99.");
- System.out.print("Please enter a number between 0-99: ");
- double fint2 = input.nextDouble();
- if (fint2 >= 0 && fint2 <= 99) {
- System.out.print("Now, enter another number between 0-99: ");
- double sint2 = input.nextDouble();
- System.out.println("Okay, so the range is between " + fint2 + " and " + sint2 + ".");
- System.out.println("Still working on it...");
- double randomNum1_2 = fint2 + (int)(Math.random() * sint2);
- double randomNum2_2 = fint2 + (int)(Math.random() * sint2);
- double randomNum3_2 = fint2 + (int)(Math.random() * sint2);
- System.out.println("Here are your random numbers:");
- System.out.println(randomNum1_2);
- System.out.println(randomNum2_2);
- System.out.println(randomNum3_2);
- } else {
- System.out.println("I told you to enter a number between 0-99, but you didn't...");
- System.out.println("So now this program is shutting down.");
- System.out.println("Goodbye!");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement