From b62c07605ac89a80d144b7e228693de77a983d03 Mon Sep 17 00:00:00 2001 From: Tenae Date: Thu, 23 Jun 2022 20:25:55 -0400 Subject: [PATCH 1/4] I added a println statement. Zipcode rocks! --- pom.xml | 4 ++++ src/main/java/Main.java | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 1efac6c..a23ddb7 100644 --- a/pom.xml +++ b/pom.xml @@ -7,6 +7,10 @@ io.zipcoder MicroLabs-OOP-TooLargeTooSmall 1.0-SNAPSHOT + + 18 + 18 + \ No newline at end of file diff --git a/src/main/java/Main.java b/src/main/java/Main.java index 05e41a9..ff177df 100644 --- a/src/main/java/Main.java +++ b/src/main/java/Main.java @@ -4,6 +4,9 @@ public class Main { public static void main(String[] args){ - + System.out.println("Zipcode rocks!"); + + + } } From a95195610dd5fc6d4cef8f3d82a5457091de9212 Mon Sep 17 00:00:00 2001 From: Tenae Date: Thu, 23 Jun 2022 21:37:23 -0400 Subject: [PATCH 2/4] Progress on Maven lab so far --- src/main/java/Main.java | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/main/java/Main.java b/src/main/java/Main.java index ff177df..d1974ac 100644 --- a/src/main/java/Main.java +++ b/src/main/java/Main.java @@ -1,12 +1,34 @@ +import java.util.Random; +import java.util.Scanner; + /** * Created by iyasuwatts on 10/17/17. */ public class Main { - + //public static String PrintResult(int userInput){ + //if(userInput < 5){ + //System.out.println("too small") + // } + //} public static void main(String[] args){ System.out.println("Zipcode rocks!"); + int userInput; + Scanner in = new Scanner (System. in); + System.out.print ("Guess a number: "); + userInput = in.nextInt(); + Math.random(); + Random num = new Random(); + int randomNum1 = num.nextInt(10); + + if (userInput < randomNum1){ + System.out.println("too small"); + } else if (userInput > randomNum1) { + System.out.println("too large"); +} else if (userInput == randomNum1) { + System.out.println("correct guess"); + } } } From d4296a23150cb1366d563917ef2f882cf698dc54 Mon Sep 17 00:00:00 2001 From: Tenae Date: Fri, 24 Jun 2022 08:53:13 -0400 Subject: [PATCH 3/4] Added counter --- src/main/java/Main.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/Main.java b/src/main/java/Main.java index d1974ac..56d374d 100644 --- a/src/main/java/Main.java +++ b/src/main/java/Main.java @@ -20,6 +20,9 @@ public static void main(String[] args){ Math.random(); Random num = new Random(); int randomNum1 = num.nextInt(10); + int userInputCount = 0; + userInputCount++; + System.out.println(userInputCount); if (userInput < randomNum1){ System.out.println("too small"); From 9847313dfae0dbef54671cc9f8154cedc06e2108 Mon Sep 17 00:00:00 2001 From: Tenae Date: Fri, 24 Jun 2022 11:11:07 -0400 Subject: [PATCH 4/4] final product --- src/main/java/Main.java | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/main/java/Main.java b/src/main/java/Main.java index 56d374d..c235f77 100644 --- a/src/main/java/Main.java +++ b/src/main/java/Main.java @@ -6,9 +6,9 @@ */ public class Main { //public static String PrintResult(int userInput){ - //if(userInput < 5){ - //System.out.println("too small") - // } + //if(userInput < 5){ + //System.out.println("too small") + // } //} public static void main(String[] args){ System.out.println("Zipcode rocks!"); @@ -23,15 +23,21 @@ public static void main(String[] args){ int userInputCount = 0; userInputCount++; System.out.println(userInputCount); + boolean correctGuess = false; + while (!correctGuess) { - if (userInput < randomNum1){ - System.out.println("too small"); + if (userInput == randomNum1) { + System.out.println("correct guess"); + } else if (userInput > randomNum1) { + System.out.println("too large"); } + else if (userInput < randomNum1) + {System.out.println("too small"); + } - } else if (userInput > randomNum1) { - System.out.println("too large"); - -} else if (userInput == randomNum1) { - System.out.println("correct guess"); + } } + } -} + + +