Assignment #54
Code
/// Name: Sam Wilson
/// Period: 6
/// Program Name: enterpin
/// File Name: enterpin.java
/// Date Finished: 12/1/2015
import java.util.Random;
import java.util.Scanner;
public class threecards
{
public static void main(String[] args)
{
Random r = new Random();
Scanner keyboard = new Scanner(System.in);
int guess, card;
card = 1 + r.nextInt(3);
System.out.println( "You slide up to Fast Sam’s card table and plop down your cash." );
System.out.println( "He glances at you out of the corner of his eye and starts shuffling." );
System.out.println( "He lays down three cards." );
System.out.println( "" );
System.out.println( "Which one is the ace?" );
System.out.println( "" );
System.out.println( " ## ## ## " );
System.out.println( " ## ## ## " );
System.out.println( " 1 2 3 " );
System.out.print( ">" );
guess = keyboard.nextInt();
if (card==1)
{
if ( guess == card )
{
System.out.println("You nailed it! Fast Sam gives you your earnings then shoots you and takes it back because this is the wild west");
System.out.println( " AA ## ## " );
System.out.println( " AA ## ## " );
System.out.println( " 1 2 3 " );
}
else
{
System.out.println( "Ha Fast Sam wins again! The ace was number " + card );
System.out.println( " AA ## ## " );
System.out.println( " AA ## ## " );
System.out.println( " 1 2 3 " );
}
}
else if (card==2)
{
if (guess==card)
{
System.out.println( "You nailed it! Fast Sam gives you your earnings then shoots you and takes it back because this is the wild west" );
System.out.println( " ## AA ## " );
System.out.println( " ## AA ## " );
System.out.println( " 1 2 3 " );
}
else
{
System.out.println( "Ha Fast Sam wins again! The ace was number " + card );
System.out.println( " ## AA ## " );
System.out.println( " ## AA ## " );
System.out.println( " 1 2 3 " );
}
}
else if (card==3)
{
if (guess==card)
{
System.out.println( "You nailed it! Fast Sam gives you your earnings then shoots you and takes it back because this is the wild west." );
System.out.println( " ## ## AA " );
System.out.println( " ## ## AA " );
System.out.println( " 1 2 3 " );
}
else
{
System.out.println( "Ha Fast Sam wins again! The ace was number " + card );
System.out.println( " ## ## AA " );
System.out.println( " ## ## AA " );
System.out.println( " 1 2 3 " );
}
}
}
}
Picture of the output