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 should we apply print preview before printing the document.​
Ghella [55]

to helps them to see how the final printed material will appear. 

7 0
2 years ago
What is the answer to 4.9 Code Practice: Question 2
bixtya [17]

Answer:

sum = 0

for i in range(20, 100, 10):

sum = sum + i

Print(sum)

Explanation:

7 0
3 years ago
Which layer of the OSI model provides a user interface in the form of an entry point for programs to access the network infrastr
Alexandra [31]

The OSI model layer that provides a user interface in the form of an entry point for software programs to access the network infrastructure is: application layer.

<h3>What is the OSI model?</h3>

OSI model is an acronym for open systems interconnection and it comprises seven (7) main layers, which typically starts from the hardware layers (layers in hardware systems) to the software layers (layers in software systems)

<h3>The layers of the OSI model</h3>

In Computer networking, the seven (7) layers of the OSI model include the following in sequential order;

  • Physical Layer
  • Data link Layer
  • Network Layer
  • Transport Layer
  • Session Layer
  • Presentation Layer
  • Application Layer

The uppermost layer of the OSI model which is the "application layer" gives software programs an access to the services that allow internet connection or network infrastructure.

Read more on OSI model here: brainly.com/question/14446612

3 0
2 years ago
What are the different ways one can adjust their communication in order to decrease noise?
soldier1979 [14.2K]

Answer

You can  whisper,write notes, text, e-mail, body language, and even use a sign language.

Explanation

By adjusting your communication in these ways one can decrease noise. Whispering is where you speak softly to someone where the information will be only heard by the person you are addressing and this will not make any noise. Also use of a text or an email where the message will be delivered electronically but not verbally. Then there is the body language which is a nonverbal  but a physical behavior used to express a certain information or also one can use sign language.

5 0
2 years ago
Read 2 more answers
If a user wants to add an expansion card to increase the memory of a computer, where should the user insert the card?
uysha [10]

into a port on the outside of the computer


6 0
2 years ago
Read 2 more answers
Other questions:
  • Write a function that takes an array of integers and its size as parameters and prints the two largest values in the array. In t
    5·1 answer
  • A blank is a link on a web page that leads to another web page.
    14·1 answer
  • If num is an int which expression always evaluates to true if num holds an odd number
    14·1 answer
  • Jin needs to add a row into his spreadsheet, but he does not want to remove any existing data. Which combination of options shou
    6·2 answers
  • Hi whats airpods good for
    15·2 answers
  • Chuck plans to go on a hiking trip. Before the hiking trip, Chuck's bank account has $129.50. He then spends $129.50 on hiking g
    6·1 answer
  • Will mark Brainliest!! What is the best hard disk compacity? Why?
    7·1 answer
  • Examples of system software include operating systems like macos, Linux, Android and
    10·2 answers
  • What type of malicious software technology is used to download and install software without the user's interaction?
    12·1 answer
  • Due TODAY!!! Can someone please help me!!!
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!