Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
My fourth program: Magic eight ball
#1
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");
        }
    }    
}
Reply


Messages In This Thread
My fourth program: Magic eight ball - by nevets04 - 11-30-2009, 04:58 PM

Forum Jump:


Users browsing this thread: 2 Guest(s)