Support Forums

Full Version: My fourth program: Magic eight ball
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Code:
import java.util.*;
import java.lang.*;
class magic
{
    public static void main(String[] args)
    {
        int x = 1;
        while (1 == 1)
        {
            Scanner cons = new Scanner(System.in);    
            String con;        
            System.out.print("Ask your question: ");            
            con = cons.next();
            Random generator = new Random();
            int fortune = generator.nextInt(4);
            if (fortune == 1)
                System.out.println("Yes");
            else if (fortune == 2)
                System.out.println("No");
            else if (fortune == 3)
                System.out.println("Maybe");
            else if (fortune == 4)
                System.out.println("Chances are slim");
            else
                System.out.println("Ask again later");
        }
    }    
}