Question

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

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.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

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);
       }
      
   }
}

Add a comment
Know the answer?
Add Answer to:
Guess my Number Create a world containing an actor (your choice) and an environment (your choice)....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Create a JavaFX game: Guess the Number create a random # between 1 and 1000 Ask...

    Create a JavaFX game: Guess the Number create a random # between 1 and 1000 Ask user for a guess; possible answers TOO LOW TOO HIGH WINNER! print guess to screen if the user wins, write the random number, and all the guesses to a file. If the user doesn't guess in 10 turns, display the number. NOTES: You may want to implement: Restart option Best Guess statistic (game 1 took 8 tries, game 2 took 5 - 5 is...

  • Can you add code comments where required throughout this Python Program, Guess My Number Program, and...

    Can you add code comments where required throughout this Python Program, Guess My Number Program, and describe this program as if you were presenting it to the class. What it does and everything step by step. import random def menu(): #function for getting the user input on what he wants to do print("\n\n1. You guess the number\n2. You type a number and see if the computer can guess it\n3. Exit") while True: #using try-except for the choice will handle the...

  • Can someone upload a picture of the code in matlab Write a "Guess My Number Game"...

    Can someone upload a picture of the code in matlab Write a "Guess My Number Game" program. The program generates a random integer in a specified range, and the user (the player) has to guess the number. The program allows the use to play as many times as he/she would like; at the conclusion of each game, the program asks whether the player wants to play again The basic algorithm is: 1. The program starts by printing instructions on the...

  • please c++ with functions *Modify the Guessing Game Write the secret number to a file. Then...

    please c++ with functions *Modify the Guessing Game Write the secret number to a file. Then write each user guess and answer to the file. (on separate lines) Write the number of guesses to the file at the end of the game. After the game is finished, ask the user if they want to play again. If 'n' or 'N' don't play again, otherwise play again! NOTE: your file should have more than one game in it if the user...

  • python question Question 1 Write a Python program to play two games. The program should be...

    python question Question 1 Write a Python program to play two games. The program should be menu driven and should use different functions to play each game. Call the file containing your program fun games.py. Your program should include the following functions: • function guess The Number which implements the number guessing game. This game is played against the computer and outputs the result of the game (win/lose) as well as number of guesses the user made to during the...

  • Need help identifying two organizational behaviors concepts/theories that apply to the organizational issue and the characters...

    Need help identifying two organizational behaviors concepts/theories that apply to the organizational issue and the characters in this chapter. We were unable to transcribe this image124 • The Ropes to Skip and the Ropes to Know give someone the benefit of the doubt, our individual ratings tend to be a bit hich When we found 20 percent of our people rated 'superior,' 50 percent 'above average 25 percent 'average,' and only 5 percent below average,' we knew something had to...

  • Develop a case study analysis in the following format Relevance of the case study to my...

    Develop a case study analysis in the following format Relevance of the case study to my work environment - application - learning impact CASE 4-1 Tambrands Overcoming Cultural Resistance Tampax, Tambrands's only product, is the best-selling tampon in their virginity if they use a tampon. When they go to the beach in the world, with 44 pencent of the global market North America and tiny bikinis, tampons arent their choike. Instead, hordes of women Europe account for 90 percent of...

  • THE WAR ON ALLERGIES SUPPOSE THAT 54.3 PERCENT of your country's population had cancer. That figure...

    THE WAR ON ALLERGIES SUPPOSE THAT 54.3 PERCENT of your country's population had cancer. That figure might set off a nationwide panic-a search for something wrong with people's diet, the environment, activity levels. In fact, that's the percentage of Americans who show a positive skin response to one or more allergens. A1 5 B The manifestations' of allergy-sneezing, itching, rashes-are signs of an une system running amok,2 attacking foreign invaders-allergens- that mean no harm. Allergens include pollen, dust mites, mold,...

  • Name: Section Number To be graded assignments must be completed and submitted on the original book...

    Name: Section Number To be graded assignments must be completed and submitted on the original book page Hypothesis Testing -As a Diagnostic Test ? Answer the following questions over the content material you just read or watched. 1. What is a false positive rate in the context of hypothesis testing? 2. What is the goal of hypothesis testing? 3. What is a Type I error, and how is it related to an "alpha level?" 4. What does it mean to...

  • Please see the articles below… 1.  What is your opinion on the subject? 2.  Which ethical views (i.e.,...

    Please see the articles below… 1.  What is your opinion on the subject? 2.  Which ethical views (i.e., utilitarian view, moral rights view, justice view, practical view) you feel are being used by both sides of the argument (i.e., for and against downloading) to justify their positions? High Court Enters File-Sharing Spat; Justices Must Determine Software Providers' Liability For Copyright Violations by Anne Marie Squeo. Wall Street Journal. (Eastern edition). New York, N.Y.: Mar 30, 2005. pg. A.2 WASHINGTON -- The Supreme...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT