1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
motikmotik
4 years ago
13

Write a program that plays a number guessing game with a Human user. The Human user will think of a number between 1 and 100, in

clusive. The program will make guesses and the user will tell the program to guess higher or lower.
Computers and Technology
1 answer:
almond37 [142]4 years ago
6 0

Answer:

<em>import java.util.Random;</em>

<em>import java.util.Scanner;</em>

<em>public class ANot {</em>

<em>    public static void main(String[] args) {</em>

<em>      Scanner in = new Scanner(System.in);</em>

<em>      Random rand = new Random();</em>

<em>      int randomNum = rand.nextInt(100)+1;</em>

<em>      System.out.println("ENTER A NUMBER TO PLAY");</em>

<em>      int userNum = in.nextInt();</em>

<em>      if(userNum<randomNum){</em>

<em>          System.out.println("Guess Higher");</em>

<em>      }</em>

<em>      else if(userNum>randomNum){</em>

<em>          System.out.println("Guess Lower");</em>

<em>      }</em>

<em>      else{</em>

<em>          System.out.println("CORRECT GUESS");</em>

<em>      }</em>

<em>    }</em>

<em>}</em>

Explanation:

  1. Use the Random class in Java to generate a random number
  2. Save the random number in a variable
  3. Use the Scanner Class to prompt user to enter a number as a guess
  4. Save the user input in a variable
  5. Use if/elseif/else statements to compare the random number and the number entered by the user.

You might be interested in
A program is expressed in a programming language. Whiat is true of the program?
zalisa [80]

Answer:

The answer is "The program can also be expressed as a binary code, but it is easier for people to understand when it is expressed in a higher programming language".

Explanation:

In the given question some details are missing that is options of the question that can be given as follows:

A. The program can also be expressed as a binary code, but it is easier for people to understand when it is expressed in a higher programming language.  

B. The program can also be represented as a binary code that reduces the likelihood of errors.  

C. Binary code can not be used for binary code, because binary code can only represent data.  

D. Some parts of the program, however, should be printed in a higher-level language for the operation.  

The computer knows the only binary language, It is a form of 0 and 1, but this language can't be understood by the user. It will convert into high-level language, that is understood by the user, that's why this option is correct.  In which accepts of option A, all options are wrong that can be described as follows:

  • In option B, It is wrong, because the user may not understand binary language, and he can also be writing some wrong code that is converted in binary code, that will increase error.
  • In option C and option D, is incorrect because all the data that is stored in the computer is in the form of binary code.

4 0
3 years ago
Tamera was responding to a complaint that one of the employees is having problems with the wired network connection on their lap
WARRIOR [948]

Answer:

tamera like from sister sister hehe

Explanation:

sorry i dont know the awnser

3 0
3 years ago
Where should a "deny all catch all" rule be positioned and why?<br> pleaseeee help!
insens350 [35]

Answer: For best performance and lowest latency, the MMU and CPU should support hardware ... broadcast, and subnet broadcast traffic with the deny-all catch-all filter rule for ... Please refer to the NetSight Wireless Manager User Guide (v5.1 or higher ) for a ... The rule must also be positioned above the 'Deny All' Default action.

Explanation:

6 0
4 years ago
Read 2 more answers
On what basis can you categorize the generations of computers
3241004551 [841]

what the answer to this question....


7 0
3 years ago
What is a current Gdp and what is a real Gdp?
SpyIntel [72]
Do u mean GPD? OORRR
5 0
3 years ago
Read 2 more answers
Other questions:
  • The Modified Greiss chemical test is used to detect the presence of what chemicals that indicate muzzle to target distance?
    11·1 answer
  • Up to 10 people is a good guideline for the size of your study group.
    15·1 answer
  • A USB zipper drive is a small data storage device that plugs into a computer's USB port.
    14·1 answer
  • How do governments correct for negative externalities?
    5·1 answer
  • What can be designed to create annoying glitches or destroy data
    11·1 answer
  • My sister put my phone in the microwave and I'm pretty sure the battery blew up. I'm too scared to open the microwave. What do I
    11·1 answer
  • Follow me on Tik-Tok​
    7·2 answers
  • Which of the following statements best compares and contrasts hot and cold type?
    12·1 answer
  • Why is John Von Neumann to a remarkable name?<br>si​
    15·1 answer
  • Explain the working principle of computer with suitable diagram​
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!