diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 7e94167..32bd1fe 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,10 +4,10 @@
-
-
+
+
-
+
@@ -62,6 +62,7 @@
"keyToString": {
"Application.Calculator.executor": "Run",
"Application.EnhancedSwitches.executor": "Run",
+ "Application.GuessANumber.executor": "Run",
"Application.Main.executor": "Run",
"Application.TempConverter.executor": "Run",
"Application.WhileLoops.executor": "Run",
@@ -121,7 +122,7 @@
-
+
@@ -283,7 +284,23 @@
1767840813715
-
+
+
+ 1767853449206
+
+
+
+ 1767853449206
+
+
+
+ 1767853460560
+
+
+
+ 1767853460560
+
+
@@ -319,7 +336,9 @@
-
+
+
+
diff --git a/out/production/java_practice/GuessANumber.class b/out/production/java_practice/GuessANumber.class
new file mode 100644
index 0000000..8732e27
Binary files /dev/null and b/out/production/java_practice/GuessANumber.class differ
diff --git a/practice_projects/src/GuessANumber.java b/practice_projects/src/GuessANumber.java
new file mode 100644
index 0000000..bf967b1
--- /dev/null
+++ b/practice_projects/src/GuessANumber.java
@@ -0,0 +1,58 @@
+import java.util.Scanner;
+import java.util.Random;
+
+public class GuessANumber {
+
+ public static void main(String[] args){
+
+ Scanner scanner = new Scanner(System.in);
+
+ // Intro at top of screen
+ System.out.println("=== !! NUMBER GUESSING GAME !! ===");
+ System.out.println("Guess a number between 1-100");
+ System.out.println("--- You have 10 guesses --- ");
+
+ // have computer pick a random number 1-100
+ Random random = new Random();
+ int number = random.nextInt(1, 101); // end range is not included. so we use 101
+
+ // Declare guess so we can use it for our while loop
+ int guess = 0;
+ int chances = 10; // Only give them 10 chances to guess it
+
+ // While logic to process guesses
+ while(guess != number){
+ System.out.print("\nEnter a guess: ");
+ guess = scanner.nextInt();
+
+ if(chances == 1){
+ System.out.println("\n####### YOU LOSE!!! #######");
+ System.out.println("--- The number was [ " + number + " ] ---");
+ break;
+ } else if(guess > number){
+ System.out.println("\nTOO HIGH. Try again");
+ chances--;
+ System.out.println("-- " + chances + " guesses remaining. --");
+ continue;
+ } else if(guess < number){
+ System.out.println("\nTOO LOW. Try again");
+ chances--;
+ System.out.println("-- " + chances + " guesses remaining. --");
+ continue;
+ } else {
+ // Winner message with the correct number
+ System.out.println("---------------------------------------");
+ System.out.println("\n***** WINNER * WINNER * WINNER *****");
+ System.out.println("********* YOU GUESSED IT! ********* \n");
+ System.out.println("\n----- The number was [ " + number + " ] -----");
+ System.out.println(" -- You had " + chances + " guesses remaining --");
+ }
+ }
+
+
+
+
+ scanner.close();
+
+ }
+}