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
expeople1 [14]
3 years ago
11

Find and fix the error in the if-else statement. import java.util.Scanner;

Computers and Technology
2 answers:
salantis [7]3 years ago
3 0

Answer:

Hi there Rumanruxi! The error is in the if statement "if(userNum = 2)".

Explanation:

The if statement in this Java code is assigning userNum the value of 2 instead of comparing it with the value of 2. For equals comparison we need to write two equals "==" in the statement as: "if (userNum == 2)". This will return true if userNum is 2 otherwise it will return false.  

andriy [413]3 years ago
3 0

Answer:

The error generated when the code is compiled:

incompatible types: int cannot be converted to boolean

Explanation:

This error is generated because the variable userNum is being assigned the value of 2.

userNum= 2

here = is the assignment operator used to assign the value 2 to the variable userNum

But here we need to compare the values with the value 2. So in order to compare the values in IF statement, == is used which is called the equality operator, instead of =

So the corrected if statement is:

if(userNum==2)

So the program prompts the user to enter a value (0,1,2,3) which is read in the userNum. Next the if statement checks if that input value is equal to 2. Num is equal to two message is displayed in the output when the if condition evaluates to true and Else part is executed if the condition evaluates to false and Num is not two message is displayed in the output.

For example the user enters a value 1 then the following message will be displayed in the output:

Num is not two

If the user enters 2 then the following message will be displayed in the output:

Num is equal to two

You might be interested in
The central point of Christian belief is that God, the Father, entered into human history as the
Simora [160]

Answer:

The central point of Christian belief is that God, the Father, entered into human history as the Son, Jesus of Nazareth, and arose as the Holy Spirit. Christian Philosophy God is the Creator of the universe.

Explanation:

4 0
3 years ago
Explain how AI smartphone software in the rental car can be a threat to privacy.
Elan Coil [88]

Answer:

The real reason why AI smartphone software in the rental car is threat to privacy is that the data transmitted can actually be exposed to security breaches in the software and so if that happens, the car is no longer under the control of the user.

Hope this helps!

4 0
3 years ago
Which of these is NOT one of the main parts of an email?
slega [8]
I think the answer is c
3 0
4 years ago
Read 2 more answers
Laurel, the manager of a software company, assumes that the male employees in his organization are more creative and innovative
grandymaker [24]

Answer:

Sterotyping

Explanation:

A stereotype is an over-generalized perception or view about a particular category of individuals or group. It is a belief that people might have concerning each and every person of a particular group. The type of expectation can differ from people to people; it can be, for instance, a belief or perception about a particular group's personality, preferences, or ability.

5 0
3 years ago
Only about 10 percent of the world’s population uses the internet.
lora16 [44]
False there are soooo many more people
Because look on our own Brainly there are more than 1,000 people
MARK ME BRAINLEST
4 0
3 years ago
Other questions:
  • A bitmap picture can be represented by hexadecimal numbers. Each two-digit hexadecimal number represents a row. To convert a num
    14·1 answer
  • Write a class called Counter that represents a simple tally counter, which might be used to count people as they enter a room. T
    9·1 answer
  • What's a good app that solves trigonometry problems?
    8·1 answer
  • What percent of the internet is the deep web?
    14·1 answer
  • Solve a single producer, single consumer problem using wait() and notifyAll(). The producer must not overflow the shared buffer,
    5·1 answer
  • How tp access to all tools in ms word
    10·1 answer
  • Is there any difference beetween the old version of spyro released on the origional and the newer ones??? or is it only change i
    8·1 answer
  • An electronic element that stores data by changing its resistance based on the current that has passed through it (similar to RR
    5·1 answer
  • Digital communication and production chapter 17
    6·1 answer
  • What will be the output, if any, when the user clicks the right mouse button?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!