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
Why do TV shows/Movies from the 90's and early 2000s look so much different compared to today?
icang [17]
Back then, movies were black and white because they had cameras that could only see black and white. In the late 1900's and early 2000's, they developed color cameras. But the common resolution and screen size was 640x480 or 4:3. Nowadays, in the late 2000's and early 2010, the widescreen format was more commonly used for many reasons. Today, the common colors are RGB 1M colors, and the resolution is 16:9. Some movies like to go even farther, like me, and use 21:9,which is super widescreen. That is more immersive than 16:9, and gives the watcher a wider, better experience. 
7 0
3 years ago
What are the answers to everfi
FinnZ [79.3K]
FutureSmart focuses on the important Middle School years by empowering students to become the stewards of their financial futures. This three hour web-based resource educates students on the practicalities of daily financial decisions and the payoffs of long-term planning. Since Middle School is an important period for positive habits
to take form and grow, this course is particularly meaningful.
Through a compelling narrative in which students play the Mayor of a town, local citizens are helped with real-life decisions. From weighing opportunity costs, to delaying instant gratification for long- term gain, students face important questions on their way to becoming FutureSmart. At the end of the course, students compose their own blueprint for the future. FutureSmart c
6 0
3 years ago
4013
grigory [225]

Answer:

IM YOUR DADDY

Explanation:

5 0
3 years ago
Read 2 more answers
#Draw patterns using fibonacci
agasfer [191]

Answer:

yidRYoYORoydzyrozoyrsoyraoyeahplhDogdaoyeayeoayorahdlHDLgksOyeayeazhldhdlHkdOyaoyaerhaahdLhKDoywaeya9yaeya9eeY9ey9

7 0
3 years ago
What kind of command can you access from the mini toolbar in Microsoft Word?
qaws [65]
Paint,calculator,camera,snipping tool,file,store,and photis

5 0
3 years ago
Other questions:
  • Why is it important to verify a customer complaint?
    6·1 answer
  • An automated search feature used by search engines to find results that match your search terms is called a spider or ?
    5·1 answer
  • Wich technology can a website use to allow you to listen to a concert live over the internet?
    10·1 answer
  • In our discussion of Computer Hardware, we talked about three essential hardware components that are there inside every computer
    14·1 answer
  • Describe the different
    12·1 answer
  • Political parties to address the interest of civil society<br>​
    7·1 answer
  • A user finished working on a computer in the lab. What should the user do so
    15·1 answer
  • Ano ang bunga ng pagsunod sa tamang konsiyensiya?
    12·2 answers
  • What might be some challenges if you’re trying to design a product for someone
    14·2 answers
  • Do anyone know how to code like I need someone do a code for me?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!