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
Why operating system is pivotal in teaching and learning
trasher [3.6K]

Answer:

Without it information flow is impossible

Explanation:

The word 'pivotal' also means crucial or vital, and so we need to consider what an operating system actually does.

Remember, merely having all the hardware of a computer would not allow you to run (install and use) programs. It is by means of an operating system that teaching programs can be installed, and it is also by means of an operating system learning can take place.

For example, a student can decode (learn) instructions/lessons from his teacher via a software program; and the software program needs an operating system to open (run) the program.

6 0
3 years ago
Is a defense of a political position an argument
shutvik [7]

Answer:

yes

Explanation:

yyyyyyyyyyeeeeeeeeesssssss

8 0
2 years ago
Explain why regular system cleanup is vital to ensuring the operating system runs efficiently.
Oksanka [162]
Cleaning up a system helps clear up the space on the drives. It may also clear up processor usage, ram usage if you uninstall programs that automatically started when the system booted. You may also delete some unwanted programs in the process.
5 0
3 years ago
Select the answer that best descibes what an opportunity cost is
TiliK225 [7]

Answer:

C.What you gain as a result of choosing one option versus another;a benefit.

Explanation:

6 0
2 years ago
What is this please help me ?
Naddika [18.5K]
A OR C is the answer
5 0
2 years ago
Read 2 more answers
Other questions:
  • #A year is considered a leap year if it abides by the #following rules: # # - Every 4th year IS a leap year, EXCEPT... # - Every
    5·1 answer
  • What are the two main components on the motherboard?
    12·2 answers
  • Elizabeth types in the following search terms: "Adoption AND cats AND NOT Persians." what results will her search provide?
    12·2 answers
  • The key schedule results in generating multiple keys from the one secret key. These multiple keys are used:
    9·1 answer
  • Read the argument below and determine the underlying principle that was used to come to the conclusion presented: It is recommen
    5·1 answer
  • The 60-watt light bulb has a 400 hour life expectency how much will it cost to operate during its time
    14·1 answer
  • 75+ (43-54)<br> -12<br> 12<br> 41
    12·2 answers
  • suppose as a head software engineer you assign the job of creating a class to a subordinate. You want to specify thirty-eight di
    11·1 answer
  • What is MVC architecture in relation to developing in web applications? How
    6·1 answer
  • BRIANLIEST!!!!!!!!!!!!!!!!
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!