From c00bf80e9e00e4c677411f948f4cd6420acfcd7c Mon Sep 17 00:00:00 2001 From: Jaime Date: Sun, 4 Feb 2024 16:34:17 -0800 Subject: [PATCH 1/2] Assignment 003 finished --- .idea/misc.xml | 2 +- .idea/vcs.xml | 6 ++++++ src/GuessStarter.java | 18 +++++++++++++++++- 3 files changed, 24 insertions(+), 2 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..869e07d 100644 --- a/src/GuessStarter.java +++ b/src/GuessStarter.java @@ -1,15 +1,31 @@ import java.util.Random; +import java.util.Scanner; +import java.util.stream.StreamSupport; /** * Starter code for the "Guess My Number" exercise. + * Author: Trevor Hartman + * Author: Jaime Ortiz */ public class GuessStarter { public static void main(String[] args) { + Scanner scanner = new Scanner(System.in); // pick a random number Random random = new Random(); + int number = random.nextInt(100) + 1; - System.out.println(number); + + System.out.println("Im thinking of a number between 1 and 100 (Including both). Can you guess what it is?"); + System.out.print("Number: "); + int userGuess = scanner.nextInt(); + + System.out.println("Your guess was: " + userGuess); + System.out.println("The number I was thinking of is: " + number); + + + int difference = (number - userGuess); + System.out.println("The difference was: " + difference); } } From 36407b5646722e3b243ad2b4837bbd9f993a398a Mon Sep 17 00:00:00 2001 From: Jaime Date: Sun, 4 Feb 2024 16:39:18 -0800 Subject: [PATCH 2/2] Assignment 003 finished --- src/GuessStarter.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/GuessStarter.java b/src/GuessStarter.java index 869e07d..9360157 100644 --- a/src/GuessStarter.java +++ b/src/GuessStarter.java @@ -17,7 +17,7 @@ public static void main(String[] args) { int number = random.nextInt(100) + 1; System.out.println("Im thinking of a number between 1 and 100 (Including both). Can you guess what it is?"); - System.out.print("Number: "); + System.out.print("Your number: "); int userGuess = scanner.nextInt(); System.out.println("Your guess was: " + userGuess); @@ -26,6 +26,8 @@ public static void main(String[] args) { int difference = (number - userGuess); System.out.println("The difference was: " + difference); + + scanner.close(); } }