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
Ang Kabihasnang ito ay umusbong sa rehiyon ng Timog Mexico
Westkost [7]

Answer:

nahh I'm still in disbelieve

8 0
3 years ago
The conceptual phase of any system or just the software facet of a system best describes the sdlc
geniusboy [140]
I think its the systems investigation phase.
5 0
3 years ago
What makes Darth Vader's sound so sinister, menacing and evil?
olganol [36]

Answer:

The volume, special effects, and the content of the speech.

Explanation:

The volume and special effects make all video productions's tone clearer. The words that Darth Vader speaks also adds to his "bad guy" character.

3 0
4 years ago
Read 2 more answers
Software that helps you navigate the web is called
Oksana_A [137]
Software that helps you navigate the web is called a web browser
7 0
3 years ago
Select the correct answer
DIA [1.3K]

Answer:

b

Explanation:

scan the images with 72DPI

5 0
3 years ago
Other questions:
  • Define the method object inc_num_kids() for PersonInfo. inc_num_kids increments the member data num_kids.Sample output for the g
    11·1 answer
  • Consider the following class definitions. public class BClass { private int x; public void set(int a) { x = a; } public void pri
    11·1 answer
  • When you use a mouse to select a row or column in a table, word displays a(n) ____?
    5·1 answer
  • 1.
    7·1 answer
  • What is that black thing on my wall?
    9·1 answer
  • A _____________ is a method of controlled entry into a facility and provides access to secure areas such as a research lab or da
    6·1 answer
  • Computer crimes are a big concern since the creation of innovative technological advances; which is/are examples of computer cri
    13·2 answers
  • Type the correct answer in the box. Spell all words correctly.
    15·2 answers
  • 2 4. What is one way to prepare for building a project budget? (1 point)​
    9·1 answer
  • Select the correct answer. Nancy has made a small web page with the new features of HTML5. She has to show this web page in scho
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!