Adding early CS challenge solutions

This commit is contained in:
2024-06-28 17:02:20 -04:00
parent 1c2266f4c5
commit 79772e0ee0
9 changed files with 343 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
import java.util.Random;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Random random = new Random();
Scanner scan = new Scanner(System.in);
int randomValue = random.nextInt(101);
int guess = -1;
while(randomValue != guess) {
System.out.print("Guess the number: ");
guess = scan.nextInt();
if(guess < randomValue) {
System.out.println("You're too low");
} else if(guess > randomValue) {
System.out.println("You're too high");
} else {
System.out.println("You guessed the right number");
}
}
scan.close();
}
}