Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Random;
- import java.util.Scanner;
- public class Problem3 {
- public static void main(String[] args) {
- Random rand = new Random();
- int randint = rand.nextInt(50);
- int tries = 0;
- Scanner scan = new Scanner(System.in);
- int guess;
- boolean win = false;
- while (win == false) {
- System.out.println("Guess a number between 1 and 50");
- guess = scan.nextInt();
- tries++;
- if (guess == randint) {
- win = true;
- }
- else if (guess < randint - 10) {
- System.out.println("You are cold, guess again.");
- }
- else if (guess > randint + 10) {
- System.out.println("you are cold, guess again.");
- }
- else if (guess <= randint - 10){
- System.out.println("you are hot, guess again.");
- }
- else if (guess <= randint + 10) {
- System.out.println("you are hot, guess again.");
- }
- else if (guess <= randint + 5) {
- System.out.println("you are VERY hot, guess again.");
- }
- else if (guess <= randint - 5) {
- System.out.println("you are VERY hot, Guess again.");
- }
- }
- System.out.println("You've won!");
- System.out.println("The number was " + randint);
- System.out.println(" it took you " + tries + " tries");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement