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
It converts Assembly Language into machine language?​
docker41 [41]

Answer:

An assembler.

Explanation:

Input is (as with any programming language) files with lists of instructions (typically assembler mnemonics), output is a binary format representing these instructions in machine language.

6 0
3 years ago
_____ are responsible for running and maintaining information system equipment and also for scheduling, hardware maintenance, an
Evgen [1.6K]

Answer:

System operators

Explanation:

This is a frontline which ensures the delivery of a reliable electricity to consumers. The duty of a system operator includes the following :manages the power grid from a set of computer console, determines the best combination of generators , investigates, plan and see to the demand and supply of power.

8 0
4 years ago
which of the following could be done to a computer that is slow to acess stored data to make it fast?
STALIN [3.7K]

Answer:

Increase the size of the hard drive

Explanation:

8 0
3 years ago
Which of the following is not a common operating system? A) Apple B) Linux C) Unix D) Windows Vista​
sleet_krkn [62]

Answer:

A) Apple

Explanation:

An operating system is a system software pre-installed on a computing device to manage or control software application, computer hardware and user processes.

This ultimately implies that, an operating system acts as an interface or intermediary between the computer end user and the hardware portion of the computer system (computer hardware) in the processing and execution of instructions.

Some examples of an operating system on computers are QNX, Linux, OpenVMS, MacOS, Microsoft windows, IBM, Solaris, VM etc.

Apple is not a common operating system.

However, MacOS is an operating system that is designed and developed by an American multinational technology company called Apple Inc.

5 0
3 years ago
What icon represents a link to an item rather than the item itself
Over [174]
I believe you are looking for a Shortcut, believing this is referring to icons on the Desktop.
3 0
4 years ago
Read 2 more answers
Other questions:
  • How to recover permanently deleted files from drive
    7·1 answer
  • When you power down a computer and turn off the rear computer case, the ______ is still on?
    7·2 answers
  • Print Job Cost Calculator (10 points)
    14·1 answer
  • I.C.T
    15·2 answers
  • Organizational sites with .org domains are usually managed by what type of organization
    7·1 answer
  • How do you implement instruction level parallelism
    11·1 answer
  • When you cut and then paste a file, what are you doing?
    7·2 answers
  • True or false = the order of cannot be changed in slide shorter view ,true or false =menu bar is located just below the title ba
    8·2 answers
  • Meryl works in the audio-video department
    10·2 answers
  • A third party that provides a computer system such as Windows, programming applications, databases, and web servers is demonstra
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!