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
____________________ are compromised systems that are directed remotely (usually by a transmitted command) by the attacker to pa
Talja [164]

Answer: Zombies

Explanation: Zombie is a computer device that is responsible for the compromising the system and making it prone to several destruction such as the Trojan horse virus,hackers and other viruses as well. Zombie makes the computer system to get malfunctioned easily ,that is without much security and various malicious functions can be performed.They basically act as the infected computer .

6 0
3 years ago
Read 2 more answers
What career opportunities are available within the floral industry?
Vsevolod [243]

Answer: The floral industry has quite an array of possible occupation pathways. You can do flower production, design, publishing, marketing, home design, engineering, retailing, commercial, research, and lots more.

6 0
2 years ago
C was created to work with UNIX systems in1972, and would be the foundation for several other programming languages, including j
san4es73 [151]

Answer:

True

Explanation:

C language is developed with the help of UNIX in 1972. It was developed by Denis Ritchie at Bell labs. many languages are developed with the help of C Platform. Such as C++, C sharp and Java.

7 0
3 years ago
How many lines are on a standard sheet of typing paper?
kotegsom [21]
60 lines on the paper
3 0
3 years ago
You would like to conduct a survey and ask your web page visitors to indicate the computer operating systems that they use. Each
satela [25.4K]

Answer:

<em>A checkbox</em>

Explanation:

A checkbox <em>(check box, tick box, tick box) is an User interface widget that allows the user to choose a binary option.</em>

Like a choice between any of two potential options that are mutually exclusive.

For instance, on a simple yes / no question, the user may have to answer ' yes ' (checked) or ' no ' (not checked).

7 0
3 years ago
Other questions:
  • A drivers touches a cars steering wheel on a hot day which term refers to the way heat is transferredd to the drivers hand
    6·2 answers
  • What is a characteristic of a wan hub-and-spoke topology?
    10·1 answer
  • What does sampling accomplish? Choose all that
    11·1 answer
  • Which are factors that go into a project plan? choose four answers
    14·1 answer
  • Does clicking ads and pop ups like the one shown in this image could expose your computer to malware?
    15·1 answer
  • Do windows+ Tab keys allow you to view documents at one time or the same time
    13·1 answer
  • Charlie makes pizza at a restaurant. The customers always compliment how great the pizza tastes. But Charlie takes a long time t
    7·2 answers
  • Mr. O would like to purchase a new computer for his home business. Mr. O's current computer runs very slow when he is running e-
    5·2 answers
  • Term of The surroundings and conditions of your workplace
    6·1 answer
  • charles, a security analyst, needs to check his network for vulnerabilities. he wants a scan that interacts with network nodes a
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!