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
You are working on a graphical app, which includes multiple different shapes. The given code declares a base Shape class with an
ycow [4]

Answer:

maybe

Explanation:

5 0
2 years ago
Common features of a thunderstorm are _____. thunder lightning rain or hail all of the above
Semmy [17]
All of the above
---------------------------------

8 0
3 years ago
Read 2 more answers
Which of the following is the BEST solution to allow access to private resources from the internet?
notsponge [240]
FTP stands for file transfer protocol. FTP is used to transfer files between computers over the Internet. FTP servers can be setup to allow users to access the information anonymously or require registration for access.
7 0
3 years ago
How do you use a iPad when it has a password ?
BaLLatris [955]
Take it to the Apple Store and they will help you or you can go on their site and press "Forgot Apple ID." If you choose the second option you have to enter the first and last name, and the email you used for the iCloud on the iPad. 
6 0
3 years ago
Read 2 more answers
Animation and transition effects will distract your audience when using a slide show presentation aid. True or false ?
lions [1.4K]
I suspect the answer they're looking for is false. However, as an experienced professional in learning and development, I can tell you that when done right these effects can enhance a presentation.
4 0
3 years ago
Read 2 more answers
Other questions:
  • Print either "Fruit", "Drink", or "Unknown" (followed by a newline) depending on the value of userItem. Print "Unknown" (followe
    15·1 answer
  • A(n _______________ is a pre-written formula that is built into excel
    12·1 answer
  • Another html/css assignment, drop css code below, thank you
    15·1 answer
  • Select the correct answer.
    12·2 answers
  • @anthonydboss23<br><br> it’s goldielove6 <br><br> .....this is not a question everyone ignore this
    11·2 answers
  • The domain in an email message tells you the
    9·2 answers
  • To give your app users the ability to open your app directly from other apps by clicking a link, you should use:.
    11·1 answer
  • Is a dot matrix printer an impact or non-impact printer
    12·2 answers
  • Basics of visual basic
    15·2 answers
  • Most spyware programs are benign in that they do not perform malicious acts or steal data. group of answer choices true false
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!