Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as Java by ciaracallanan ( 5 years ago )
/**
 * This program tells the user their fortune.
 * 
 * @ccallanan
 * 4-1-21
 */
import java.util.Scanner;
public class FortuneTeller
{
    public static void main(String[] args)
    {
        Scanner in = new Scanner(System.in);
        
        System.out.println("Welcome to Fortune Teller, ask a question and I will give you your fortune.");
        String question = in.nextLine();
        int fortune = (int) (Math.random() *5);
        String repeat = "Y"; 
        while(repeat.equalsIgnoreCase("Y"))
        {
            if (fortune == 1)
                System.out.println("Yes");
            else if (fortune==2)
                System.out.println("NO!");
            else if (fortune == 3)
                System.out.println("Unlikely");
            else if (fortune == 4)
                System.out.println("Inconclusive");
            else
                System.out.println("Definitely");
                
                System.out.println("Press Y then enter to ask another question, any other key to exit.");
                repeat = in.nextLine();
        }
        
        System.out.println("Thank you for playing!")
        
    }
}

 

Revise this Paste

Your Name: Code Language: