import java.util.Random; import java.util.Scanner; /* * The Lottery example code is on the textbook's website. This code intentionally * includes some errors so we can use it learn the debugging functions in Eclipse. */ public class LotteryWithErrors { public static void main(String[] args) { Random random = new Random(); int lottery = random.nextInt(10); Scanner in = new Scanner(System.in); System.out.print("Enter your lottery pick (two digits): "); int guess = in.nextInt(); in.close(); int lotteryDigit1 = lottery / 10; int lotteryDigit2 = lottery % 10; int guessDigit1 = guess % 10; int guessDigit2 = guess % 10; if (guess == lottery) System.out.println("Exact match: you win $10,000"); else if (guessDigit1 == lotteryDigit1 && guessDigit2 == lotteryDigit2) System.out.println("Match all digits: you win $3,000"); else if (guessDigit1 == lotteryDigit1 || guessDigit1 == lotteryDigit2 || guessDigit2 == lotteryDigit1 || guessDigit2 == lotteryDigit2) System.out.println("Match one digit: you win $1,000"); else System.out.println("Sorry, no match"); } }