Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions src/main/java/Main.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,35 @@
import java.util.Random;
import java.util.Scanner;

/**
* Created by iyasuwatts on 10/17/17.
*/
public class Main {

public static void main(String[] args){

public static void main(String[] args) {

// Generate & assign random number
Random rand = new Random();
int n = rand.nextInt(10) + 1;
int userNum = 0;

// Collect user input number
do {
Scanner sc = new Scanner(System.in);
System.out.println("Enter a number between 1 and 10: ");
userNum = sc.nextInt();

// Compare user input to random number and print statements accordingly
if (userNum < n) {
System.out.println("Too small. Guess again.");
} else if (userNum > n) {
System.out.println("Too large. Guess again.");
}

}
while (userNum != n);

System.out.println("Correct guess.");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should track and report on how many guesses taken. please add that?


}
}