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
lutik1710 [3]
3 years ago
9

The template code provided is intended to check whether an integer entered by the user is outside of the range 20-29 (inclusive)

. If it is outside of this range the program should print a warning and change the number to 25. However, when using De Morgan's law to simplify this code, the programmer has made some mistakes. Can you correct the errors so the code functions as intended? code: Scanner scan = new Scanner(System.In); System.Out.Println("Enter a number in the twenties"); int num = scan.NextInt(); if(num < 20 && num > 30){ System.Out.Println("That's not in the twenties!"); num = 25; } System.Out.Println("Your number is " + num);
Computers and Technology
1 answer:
irakobra [83]3 years ago
8 0

Answer:

Change if(num < 20 && num > 30)

to

if(num < 20 || num > 30)

Explanation:

The code has lots of errors most of which are as a result of case sensitivity of java programming language

The following errors were corrected.

All System.Out.Println were changed to System.out.println

scan.NextInt() was changed to scan.nextInt()

Now to the actual correction that needs to be made;

The programmer's error was in using the conditional statement.

The programmer used if(num < 20 && num > 30) as its condition which means that if num is less tha 20 and at the same time greater than 30

This is impossible because no number is greater than 30 and less than 20 at the same time.

So, the correction made was to change the && (and) to || (or) which means that numbers greater than 30 or less than 20.

<em></em>

<em>This corrects the programmer's mistake</em>

<em>See attachment for complete code</em>

Download txt
You might be interested in
What was the first 1.0.1 version of openssl that was not vulnerable to heartbleed?
vovikov84 [41]
I suggest you to read OpenSSL changelogs to make it more clear. As there's not enough space to describe how it works. But heartbleed resistan version was 1.0.2, as I know.
5 0
3 years ago
Read 2 more answers
What is the recommended solution to configure this automated behavior? UC has a requirement that an opportunity should have a fi
Dmitry_Shevchenko [17]
The answer will need to be workflow.
8 0
3 years ago
What is the output of this program?
Charra [1.4K]

Answer:

20

Explanation:

assuming the print statement is not indented, the program effectively calculates 2+5+6+7.

The range(...) is <em>excluding </em>the end value (8 in this case).

3 0
3 years ago
Read 2 more answers
How is an operating system like a translator?
emmasim [6.3K]

Answer:

Operating systems work like translators because they are able to take software and hardware, and put it all together to work in a way that is readable and usable for the consumer.

5 0
3 years ago
Kristine has been receiving many emails from a certain address. She thinks that these emails might harm her computer. Which acti
Paraphin [41]
Report the email adress then block them 
6 0
3 years ago
Read 2 more answers
Other questions:
  • An _________ is a phrase formed from the first letters of words in a set phrase or series of words a. Acronymic sentence c. Basi
    7·2 answers
  • What would happen to a eukaryotic cell if all its mitochondriawere destroyed
    7·1 answer
  • Given four inputs: a, b, c &amp; d, where (a, b) represents a 2-bit unsigned binary number X; and (c, d) represents a 2-bit unsi
    6·1 answer
  • As in algebra, you can use brackets to override the order of operations Excel follows to perform formula calculations. True or f
    13·1 answer
  • 1. provide at least 3 properties and 3 methods of the object computer.
    8·1 answer
  • Please help me. Adnan also wants to add a photograph of a bridge. It is on another PowerPoint presentation that is open in a dif
    11·1 answer
  • Help me. thank you very much
    14·1 answer
  • A while loop should be used if you want the user to watch the same video three times.
    13·1 answer
  • What is the "Driver's Compact Law"?
    8·2 answers
  • The field that uses technology to manipulate and use information to improve healthcare is known as:_______
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!