PROGRAMMING AND CODE
Assignemnt #58
Code
/// Name: Justin Li /// Period 7 /// Program Name: Dice /// File Name: Dice.java /// Date Finished: 12/2/15 import java.util.Scanner; import java.util.Random; class OneShotHiLo { public static void main(String[]args) { Random r = new Random(); Scanner keyboard = new Scanner(System.in); int guess, real; real = 1 + r.nextInt(100); System.out.println("I'm thinking of a number between 1-100. Try to guess it.\n"); guess = keyboard.nextInt(); if (guess > real) { System.out.println("Sorry that was too high. I was thinking of " + real); } else if (real > guess) { System.out.println("Sorry that was too low. I was thinking of " + real); } if (guess == real) { System.out.println("WOW that is right, what are the odds.\n"); } } }