\"CS480C_HW1_SANDEEPANUGLA_10805\" - CS480C Homework 1 import java.lang import java.util.Scanner public class Programcfw*Its the main entry

"CS480C_HW1_SANDEEPANUGLA_10805" - CS480C Homework 1...

This preview shows page 1 - 2 out of 4 pages.

CS480C Homework # 1 import java.lang.*; import java.util.Scanner; public class Program{ /** *Its the main entry point for the appication */ public static void main(String args[]) { int playerFirst, playerSecond, playerThird, playerTotal, dealerFirst, dealerSecond, dealerThird, dealerTotal; String playerChoice; System.out.println("Welcome to BLACKJACK!!!!\n\n"); playerFirst = (int)(Math.random()*11 + 1); playerSecond = (int)(Math.random()*11 + 1); playerTotal = playerFirst + playerSecond; if(playerTotal == 21) { System.out.println("BLACKJACK!!!"); System.exit(0); } System.out.println("User get" +playerFirst + "and a " +playerSecond); System.out.println("User Total" +playerTotal); dealerFirst = (int)(Math.random()*11 + 1); dealerSecond = (int)(Math.random()*11 + 1); dealerTotal = dealerFirst + dealerSecond; System.out.println("Dealer has" +dealerFirst + "shows, and a hidden card"); System.out.println("Dealer total is hidden"); System.out.println("would you like to 'hit' or 'stay' ?"); Scanner inputPlayer = new Scanner(System.in); playerChoice = inputPlayer.nextLine(); if(playerChoice.equals("hit")) //hit or stay choice for player { playerThird = (int)(Math.random()*11 + 1);
Image of page 1
Image of page 2

You've reached the end of your free preview.

Want to read all 4 pages?

  • Fall '13
  • #, Jack, System.out.println

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture