Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Guess my Number Create a world containing an actor (your choice) and an environm

ID: 3753069 • Letter: G

Question

Guess my Number
Create a world containing an actor (your choice) and an environment (your choice). When the world begins to play, the actor selects a WholeNumber at random in the range 1..99. The actor then repeatedly asks you to guess the number. If you guess too high, the actors say “Too high” and if you guess too low, the actor says “Too low.” The actor keeps track of the number of erroneous guesses. If you guess correctly, the actor says “Correct, you only needed # guesses.” You might modify the game to allow a maximum of, say, 10 guesses, after which the actor might say “You lose!”

I do not know if anyone on chegg knows the language of Alice3, but I'm confused on this problem. I am not sure how to take in user input.

Explanation / Answer

Guess.java

import java.util.*;
public class Guess{
   public static void main(String[] args){
       Scanner scan=new Scanner(System.in);
       int random=(int)(Math. random()*((99 - 1) + 1) + 1);
       int count=1;
       boolean status=false;
       while(count<=10){
           System.out.println("Enter the number:");
           int c=scan.nextInt();
           if(c<random){System.out.println("Too low.");}
           if(c>random){System.out.println("Too high.");}
           else if(c==random){
               System.out.println("Correct, you only needed "+count+" guesses.");
               status=true;
               break;
           }
           count++;
       }
       if(status==false){
           System.out.println("You lose!");

       System.out.println("Number is "+random);
       }
      
   }
}