Skip to content
Open
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions java/lang/annotations.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<root>
<item name='java.lang.String'>
<annotation name='java.lang.Deprecated'/>
</item>
</root>
24 changes: 22 additions & 2 deletions src/main/java/Main.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,29 @@
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) {
Scanner userInput = new Scanner(System.in);
Random rand = new Random();
int count = 0;
int mysteryNum = rand.nextInt(1000);
System.out.println("Please guess to find the mystery number. The mystery number is between 0 and 1000.");
while (true) {
int userNum = userInput.nextInt();
count++;
if (userNum > mysteryNum) {
System.out.println("Too large. Please guess again.");
} else if (userNum < mysteryNum) {
System.out.println("Too small. Please guess again.");
} else if (userNum == mysteryNum) {
System.out.println("Correct guess!");
System.out.println("It took you " + count +" guesses.");
break;
}
}
}
}