boolean game
802991Oct 4 2010 — edited Oct 5 2010Hello there. Trying to make a boolean game, and thought about haveing a randomizer, so people cannot just memorize the order.
import java.util.*;
public class Boolean_and_if_testing
{
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
System.out.println("Hello there! We will be playing a game. 25 percent chance to win. Choose one: True/False.");
boolean ans = in.nextBoolean();
if (ans == false)
System.out.println("You have lost!!! D:");
if (ans == true)
System.out.println("You have won! :D\nNow choose another choice: True/False.");
if (ans == false)
System.exit(1);
if (ans == true)
ans = in.nextBoolean();
if (ans == true)
System.out.println("You have lost!!! D:");
if (ans == false)
System.out.println("You have won! :D");
}
}
Any help?
Sorry for the layout of the code, I am new to the forums and do not know how to do the code format.