diff --git a/.idea/misc.xml b/.idea/misc.xml index cf9abe6..b95853c 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,4 +1,3 @@ - diff --git a/Java-Assignment-003.iml b/Java-Assignment-003.iml index e1006ff..a6b4f56 100644 --- a/Java-Assignment-003.iml +++ b/Java-Assignment-003.iml @@ -1,11 +1,25 @@ - - - - - - - - - - - \ No newline at end of file +import java.util.Random; +import java.util.Scanner; + +/** + * Starter code for the "Guess My Number" exercise. + */ +public class GuessStarter { + + public static void main(String[] args) { + String newLine = System.lineSeparator(); + Scanner numInput = new Scanner(System.in); + System.out.println("I'm thinking of a number between 1 and 100." + newLine + "Can you guess what it is?"); + // pick a random number + int userGuess = numInput.nextInt(); + System.out.println("Your Guess is:" + userGuess + "?"); + Random random = new Random(); + int number = random.nextInt(100) + 1; + System.out.println(number); + System.out.println("The number that I was thinking of is:" + number); + int difference = Math.abs(userGuess - number); + //Absolute value of difference + System.out.println("Your guess was off by: " + difference); + } + +} \ No newline at end of file diff --git a/src/GuessStarter.java b/src/GuessStarter.java index 64984df..7c11132 100644 --- a/src/GuessStarter.java +++ b/src/GuessStarter.java @@ -1,15 +1,2 @@ -import java.util.Random; -/** - * Starter code for the "Guess My Number" exercise. - */ -public class GuessStarter { - - public static void main(String[] args) { - // pick a random number - Random random = new Random(); - int number = random.nextInt(100) + 1; - System.out.println(number); - } - -} +} \ No newline at end of file