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
Business Professionals of America, and Future Business Leaders of America – Phi Beta Lambda are both open to business students a
AVprozaik [17]

Answer:

Middle, High and College

Explanation:

8 0
3 years ago
Read 2 more answers
In the context of intentional computer and network threats a ____ is a programming routine built into a system by its designer
lara31 [8.8K]

Answer:

a. backdoor

backdoor (also called a trapdoor) is a programming routine built into a system by its designer or programmer. It enables the designer or programmer to bypass system security and sneak back into the system later to access programs or files.

6 0
3 years ago
Read 2 more answers
HELP MEEE PLEASE!!!
Vladimir [108]

Answer:

b goes with 1 c goes with 3 and a goes with 2

Explanation:

3 0
3 years ago
An independent penetration testing company is invited to test a company's legacy banking application developed for Android phone
erastovalidia [21]

2010s is the one who created the iPhone

8 0
3 years ago
What are the common causes of signal loss in fiber optic cable connectors
timurjin [86]
Bending, twisting, or the overall age of the cable, or other stuff like that.
8 0
3 years ago
Other questions:
  • Which of the following is NOT a sedimentary structure?
    8·2 answers
  • Jim is an experienced security professional who recently accepted a position in an organization that uses Check Point firewalls.
    7·1 answer
  • In the borders and shading dialog box where would you look to see if your border will have two sides
    11·2 answers
  • What is good prossesser
    15·2 answers
  • We will cover email use and management. Training topics include:
    5·1 answer
  • Create a new Java class called AverageWeight. Create two arrays: an array to hold 3 different names and an array to hold their w
    13·1 answer
  • Consider this binary search tree:______.
    12·1 answer
  • True or False? You should never move an injured person.<br> True<br> False
    6·1 answer
  • When using the text command, what needs to be around the word or words you<br> want to appear?
    10·1 answer
  • please write out an accurate code for the question below also please explain or I'll report you ( Thanks :) )
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!