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
Explain how to implement two stacks in one array A[1..n] in such a way that neither stack overflows unless the total number elem
algol [13]

Answer:

Check explanation

Explanation:

Two stacks can make use of one array by utilizing various stack pointers that begins from different ends of an array. Looking at the array A[1...n], the first stack will drive elements that starts from position 1 as well as to move its' pointer to n.

The Second stack will begin at the n position and motion its' pointer to 1. The best likely divide is to offer each stack a half of an array. whenever any of two stacks transverse the half-point, an overflow can happen but for that overall number of elements, it must be n

5 0
3 years ago
If you need to multiply 400, 2, and 1 ½, what would you type on the numeric keypad?
balandron [24]
You will type

400*2*1.5

1.5 is another way to say 1 1/2
4 0
3 years ago
Read 2 more answers
Which of the following are advantages of cloud computing?
Leona [35]
Hahahahaha lawllakad
7 0
3 years ago
Read 2 more answers
i'm actually really smart so if u need help just ask me or leave me a comment. im 16 and my name is lexi
kicyunya [14]
Umm okay...

The density of water is 1.0 g/cm^3
Which will float in water

A.) Ice (Density = 0.92 g/cm^3) Float or sink

B.) Wood (Density = 0.45 g/cm^3) Float or sink

C.) Bone (Density = 1.7 g/cm^3) Float or sink

If you help answer this it will be much appreciated thank you
8 0
3 years ago
Read 2 more answers
Data warehouse contains historical data obtained from the _____.
STALIN [3.7K]
D. operational databases
3 0
3 years ago
Other questions:
  • Fill in the blank
    13·2 answers
  • How do you change brightness on acer laptop?
    7·1 answer
  • A network technician is assisting the security team with some traffic captures. The security team wants to capture all traffic o
    9·1 answer
  • Describe Relational Query Languages and Operations.
    15·1 answer
  • O O O O O O O
    9·1 answer
  • A group of students writes their names and unique student ID numbers on sheets of paper. The sheets are then randomly placed in
    15·1 answer
  • Which devices are used in networking
    15·1 answer
  • Stacy plans to print her contacts and would like to choose an option that will print select information for each contact in a bu
    12·1 answer
  • List 10 examples of computer ethics<br>(please give even 1 if you can, I need it urgently) ​
    10·1 answer
  • Web résumés allow you to include extra graphics and images that you would not include in a traditional résumé. please select the
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!