HW03 Solution2

HW03 Solution2 - sum = sum card System.out.println"New card" card if(sum< 21 System.out.print"Stand(0 or hit(1" userChoice =

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Sheet1 Page 1 // Solution to Homework #3, Problem #2 import java.util.Scanner public class HW03_2 { public static void main(String args[]) { Scanner scanner = new Scanner(System.in) int card int userChoice int sum userChoice = 1 sum = 0 card = (int) (Math.random() * 10) + 1
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: sum = sum + card System.out.println("New card: " + card) if (sum < 21) { System.out.print("Stand (0) or hit (1)? ") userChoice = scanner.nextInt() } } System.out.println("Your total is " + sum + ".") if (sum > 21) System.out.println("You busted!") } }...
View Full Document

This note was uploaded on 04/10/2008 for the course ENGR 131 taught by Professor Xiaowei during the Spring '07 term at Case Western.

Ask a homework question - tutors are online