Guest User

Untitled

a guest
Jan 24th, 2018
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.30 KB | None | 0 0
  1. import java.util.Random;
  2. import java.util.Scanner;
  3.  
  4.  
  5. public class Script{
  6.  
  7.     private static final Random randomNum = new Random();
  8.     private static Scanner userInput = new Scanner(System.in);
  9.     private static int randomResponse = 1 + randomNum.nextInt(10);
  10.  
  11.     public static void main(String args[]){
  12.         String userQuestion = "";
  13.        
  14.         System.out.println("Please ask the Magic 8-Ball a question, and it will give you a response.\n");
  15.         System.out.print("Magic 8-ball...");
  16.         userQuestion = userInput.nextLine();
  17.        
  18.         System.out.printf("\n%s", determineResponse());
  19.        
  20.        
  21.     }
  22.    
  23.     private static String determineResponse(){
  24.         String response = "";
  25.         switch(randomResponse){
  26.             case 1:
  27.                 response = "It is certain.";
  28.                 break;
  29.             case 2:
  30.                 response = "Reply hazy, try again.";
  31.                 break;
  32.             case 3:
  33.                 response = "Don't count on it.";
  34.                 break;
  35.             case 4:
  36.                 response = "It is decidedly so";
  37.                 break;
  38.             case 5:
  39.                 response = "Ask again later.";
  40.                 break;
  41.             case 6:
  42.                 response = "My reply is no.";
  43.                 break;
  44.             case 7:
  45.                 response = "Without a doubt.";
  46.                 break;
  47.             case 8:
  48.                 response = "Better not tell you now";
  49.                 break;
  50.             case 9:
  51.                 response = "Outlook not so good.";
  52.                 break;
  53.             case 10:
  54.                 response = "Most likely.";
  55.                 break;
  56.         }
  57.         return response;
  58.     }
  59. }
Add Comment
Please, Sign In to add comment