Advertisement
ScreamGM

Untitled

Mar 23rd, 2017
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.50 KB | None | 0 0
  1. import java.util.Scanner;
  2. import java.util.Random;
  3. public class Magic_8_Ball {
  4.  
  5.     public static void main(String[] args) {
  6.         String question;
  7.        
  8.         Scanner input = new Scanner(System.in);
  9.         Random rnd = new Random();
  10.         System.out.println("WELCOME TO MAGIC 8 BALL");
  11.        
  12.         while (true)
  13.         {
  14.            
  15.        
  16.         System.out.printf("\n%-40s","Enter a Question (Q to quit):");
  17.         question = input.next();
  18.         int num = rnd.nextInt(12) + 1;
  19.        
  20.         if(question.equalsIgnoreCase("q"))
  21.         {
  22.             System.out.print("Thank you for playing! Goodbye!");
  23.             break;
  24.         }      
  25.         else if (num == 1)
  26.         {
  27.             System.out.println("Outlook not so good!");
  28.         }
  29.         else if (num == 2) 
  30.         {
  31.             System.out.println("Reply hazy, try again!");
  32.         }
  33.         else if (num == 3)
  34.         {
  35.             System.out.println("Most likely");
  36.         }
  37.         else if (num == 4)
  38.         {
  39.             System.out.println("Without a doubt!");
  40.         }
  41.         else if (num == 5)
  42.         {
  43.             System.out.println("Don't count on it!");
  44.         }
  45.         else if (num ==  6)
  46.         {
  47.             System.out.println("Yes definitely!");
  48.         }
  49.         else if (num == 7)
  50.         {
  51.             System.out.println("You can count on it!");
  52.         }
  53.         else if (num == 8)
  54.         {
  55.             System.out.println("As I see it, yes!");
  56.         }
  57.         else if (num == 9)
  58.         {
  59.             System.out.println("My sources say no!");
  60.         }
  61.         else if (num == 10)
  62.         {
  63.             System.out.println("My reply is no!");
  64.         }
  65.         else if (num == 11)
  66.         {
  67.             System.out.println("Outlook good!");
  68.         }
  69.         else if (num == 12)
  70.         {
  71.             System.out.println("Very doubtful!");
  72.         }
  73.        
  74.         input.close();
  75.        
  76.        
  77.        
  78.         }
  79.        
  80.        
  81.        
  82.     }
  83.  
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement