Project3

Code

import java.util.Random;
import java.util.Scanner;

public class Project3
{
	public static void main ( String[] args ) throws Exception
	{
		Random r = new Random();
        Scanner keyboard = new Scanner(System.in);
        
        String ans, HS;
        
        int tot;
        
        tot = 0;

		int a = 1 + r.nextInt(10);
        int b = 1 + r.nextInt(10);
        int c = 1 + r.nextInt(10);
        int d = 1 + r.nextInt(10);
        
        
        System.out.println(" Welcome to Rigged Blackjack ");
        System.out.println(" Are you ready? " );
        ans = keyboard.next();
        
        if ( ans.equals("yes"))
        {
            System.out.println(" Good " );
        }
        else
        {
            System.out.println("Too bad");
        }
        // doesn't even matter
        
        System.out.println(" Now let me give you your cards ");
        
        Thread.sleep(900);
        //wanted to delay it a little
        
        System.out.println(" The Dealer shows a " + c);
        
        Thread.sleep(900);
        
        System.out.println("You drew a " + a + " and a " + b + " which is a total of " + (a+b));
        HS = keyboard.next();
        tot = a+b;
        
        
        while ( HS.equals("hit"))
        {
            int e = 1 + r.nextInt(10);
            tot = tot+e;
            
            
            
            System.out.println(" So now your total is " + (tot+e) + " Hit or stay");
            HS = keyboard.next();
            
            
            if (tot==21)
            {
                System.out.println(" You win " );
                HS="WIN";
            }
            else if (tot>21)
            {
                System.out.println("You lost ");
                HS="Lose";
            }
            
            
            
        }
        
        while ( HS.equals("stay"))
        {
            System.out.println(" Okay now its my turn ");
            System.out.println(" Dealer shows his card, and his total is " + (c+d));
            int tot1 = c+d;
            
            while( tot1 < 16 )
            {
                Thread.sleep(900);
                System.out.println(" HIT!!! " );
                int f = 1 + r.nextInt(10);
                tot1 = tot1+f;
                
                Thread.sleep(900);
                
                System.out.println(" Dealers total is " + tot1 );
                
                
                if (tot1>21)
                {
                    System.out.println(" Dealer loses " );
                    HS="Loses";
                }
                else if (tot1==21)
                {
                    System.out.println(" Dealer Wins " );
                    HS="Wins";
                }
                else if (tot1>=16)
                {
                    System.out.println(" Stay" );
                    HS="Tie";
                }
                
            }
            if (tot > tot1)
            {
                System.out.println(" You win");
            }
            else
            {
                System.out.println("Dealer Wins");
            }
        }
        
            
        
    }
}

Project3

Project3