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
How can learning opportunities for AI be extended to all
statuscvo [17]

Answer:

Learning opportunities for AI can be extended to all through the inclussion of courses and different teaching methods related to Artificial Intelligence, new technologies, computer science, programming and, in short, everything related to the digital world, in the educational plans at the national level. This is so because artificial intelligence and computer systems are the basis for the development of the new tools jobs of tomorrow. Thus, education in these subjects is essential so that citizens can enter the labor market once they acquire the necessary age, having the knowledge to do so in a proper way.

6 0
2 years ago
Four-pair UTP uses ________ connectors a)snap b)ST or SC c)None of these
Oliga [24]

Explanation & answer:

Four pair UTP (unshielded twisted pair) cables are common cables with RJ45 connectors.  Most RJ45 connectors have a snap to lock the male connector in place.

ST and SC connectors are for fibre-optics.

4 0
3 years ago
Fill in the blank to complete the sentence. -------------------- is used to store and process data over the Internet using compu
Trava [24]

Answer:cloud computing

Explanation:

6 0
3 years ago
Please help! Answers that do not relate to this topic will be REPORTED!
zmey [24]

Answer:

answer for number A is

2. the ability to be  either relative or absolute

B. 2 bytes

C. in a buffer

Explanation:

6 0
2 years ago
MAN on metropolitan area network is a network spanning a large distances of a few kilometre like a city true or false​
ser-zykov [4K]

Answer:

True

Explanation:

It is True

8 0
3 years ago
Other questions:
  • Prewritten, commercially available sets of software programs that eliminate the need for a firm to write its own software progra
    5·1 answer
  • Design and implement your own simple class to represent any household item of your choice (toaster, fan, hair dryer, piano ...)
    11·1 answer
  • type of weapon of mass decruction taht spreads deadly radioactive material by way of conventinal explosion
    15·1 answer
  • Which describes which CTSO each student should join?]
    7·1 answer
  • 1000base-t is a standard for achieving throughputs ____ times faster than fast ethernet over copper cable.
    8·1 answer
  • (Display four patterns using loops) Ask the user to enter an integer to
    8·1 answer
  • What is an operating system? What are the main functions of a modern general purpose operating system?
    7·1 answer
  • Why, y did brainly just do that........or did it just happen to me
    12·2 answers
  • Travis just got promoted to network administrator after the previous administrator left rather abruptly. There are three new hir
    14·1 answer
  • WILL GIVE BRAINLIEST!!!!!!!
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!