Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import java.util.Random;
- public class Magic_8_Ball {
- public static void main(String[] args) {
- String question;
- Scanner input = new Scanner(System.in);
- Random rnd = new Random();
- System.out.println("WELCOME TO MAGIC 8 BALL");
- while (true)
- {
- System.out.printf("\n%-40s","Enter a Question (Q to quit):");
- question = input.next();
- int num = rnd.nextInt(12) + 1;
- if(question.equalsIgnoreCase("q"))
- {
- System.out.print("Thank you for playing! Goodbye!");
- break;
- }
- else if (num == 1)
- {
- System.out.println("Outlook not so good!");
- }
- else if (num == 2)
- {
- System.out.println("Reply hazy, try again!");
- }
- else if (num == 3)
- {
- System.out.println("Most likely");
- }
- else if (num == 4)
- {
- System.out.println("Without a doubt!");
- }
- else if (num == 5)
- {
- System.out.println("Don't count on it!");
- }
- else if (num == 6)
- {
- System.out.println("Yes definitely!");
- }
- else if (num == 7)
- {
- System.out.println("You can count on it!");
- }
- else if (num == 8)
- {
- System.out.println("As I see it, yes!");
- }
- else if (num == 9)
- {
- System.out.println("My sources say no!");
- }
- else if (num == 10)
- {
- System.out.println("My reply is no!");
- }
- else if (num == 11)
- {
- System.out.println("Outlook good!");
- }
- else if (num == 12)
- {
- System.out.println("Very doubtful!");
- }
- input.close();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement