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
What do rocket scientists mean when they say, "forces come in pairs?"
zhenek [66]
According to Newton's third law, for every action force there is an equal (in size) and opposite (in direction) reaction force.
6 0
3 years ago
When did the silver market drop sharply, hurting Bolivia's income?
seropon [69]
The silver market dropped sharply in <span>1898,</span> hurting Bolivia's income.

The entire mining business was in decline as a result of destruction, flooding, and abandonment of mines. Lack of investment and insufficiency of labor contributed to a pointy drop by silver production. Agricultural production was low, and Bolivia had to import food, even the essential staples consumed by the Indian population. the government had serious money difficulties as a result of the massive military expenditures and debt payments to the Republic of Peru as compensation for the military of liberation. of these issues were aggravated by the isolation of the new republic from the skin world and therefore the difficulties of securing its borders.
7 0
3 years ago
Read 2 more answers
Although females are born with approximately 2 million ova, this number declines to
Pepsi [2]

Answer: 1

Explanation:

a woman is born with about 1-2million ova, during puberty this figure reduce to between 600,000 and 1million. during her child bearing years the figure drops down to about 300,000 to 400,000 ova, out of which only about 500 would be ovulated during her reproductive years. the rest die out during menopause.

8 0
3 years ago
What is Network Address Translation (NAT) and how does it work in a network?
Allisa [31]

Answer:

 Network address translation (NAT) is a method for designing the IP address and it basically operate on router. NAT usually connect two network together and translate the unique and private address into the legal address.

Network address translation is a technique that works in network  for re-mapping the IP address into another by modify the network address information into the IP packet header. NAT gateway are used for the entire private network.  

The network address translation use both the security and economical purpose in an organization to limit the public IP address.

5 0
3 years ago
One way to save time and get to the colleges that you are most interested in at a college fair is to
son4ous [18]

Answer:

Identify the location of the college stand in advance.

Explanation:

One way to save time and get to the colleges that you are most interested in at a college fair is to find out in advance the information about the fair, the colleges that are participating and from that pick the more interesting ones and identify the location of their stands. Like that when you arrive to the fair you can go directly to them and find them easily which will save you a lot of time as you won't be walking around the whole place to find them.

8 0
3 years ago
Read 2 more answers
Other questions:
  • Helen has no experience in security. She would like to earn a certification that demonstrates that she has the basic knowledge n
    15·1 answer
  • Which of the following is an advantage of algorithmic thinking? Select all that apply.
    6·1 answer
  • Which of the following is the part of a digital camera that acts as the film?
    11·1 answer
  • Some touch screens recognize when you touch the screen with two fingers or two hands. If you are looking for a device on which y
    11·1 answer
  • A(n) _____ investigates, analyzes, designs, develops, installs, evaluates, and maintains a company’s information systems.​
    10·1 answer
  • What format are a setups program file in before executed?
    12·1 answer
  • Examine the following declarations and definitions for the array-based implementations for the Stack and Queue ADTs. Assume that
    14·1 answer
  • What is an example of a culture block
    8·1 answer
  • If the old and new systems are operated side by side until the new system has proven itself, this type of system conversion plan
    11·1 answer
  • Tick (/) the correct answers.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!