From 32ae8b5cb0b931c021ab416beff16d40bc0415e3 Mon Sep 17 00:00:00 2001 From: csprtheghst Date: Sun, 4 Feb 2024 17:34:04 -0800 Subject: [PATCH] Completed Java Assignment 003 --- .idea/misc.xml | 2 +- .idea/vcs.xml | 6 ++++++ src/GuessStarter.java | 19 +++++++++++-------- 3 files changed, 18 insertions(+), 9 deletions(-) create mode 100644 .idea/vcs.xml diff --git a/.idea/misc.xml b/.idea/misc.xml index cf9abe6..cbbff6a 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/GuessStarter.java b/src/GuessStarter.java index 64984df..85e80cd 100644 --- a/src/GuessStarter.java +++ b/src/GuessStarter.java @@ -1,15 +1,18 @@ import java.util.Random; - -/** - * Starter code for the "Guess My Number" exercise. - */ +import java.util.Scanner; +// Trevor Hartman +// Tanner Wilson 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); + System.out.println("I'm thinking of a number between 1 and 100 (including both). Can you guess what it is?"); + System.out.print("Your guess: "); + Scanner scanner = new Scanner(System.in); + int userGuess = scanner.nextInt(); + System.out.println("You guessed: " + userGuess); + System.out.println("The number I was thinking of is: " + number); + int difference = Math.abs(userGuess - number); + System.out.println("The difference is: " + difference); } - }