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
1. What is JavaScript?
rosijanka [135]

Answer:

1. JavaScript is a dynamic computer language used to primarily code and create system functions.

2. The people who designed the Apple 1 Computer were

  • Steve Wozniak
  • Steve Jobs

3. The founder of Apple was Steve Jobs. He passed away from pancreatic cancer.

Hope this helps you!

3 0
3 years ago
Hey system has defined specific Quetion that describe how signals are sent over connections. Which layer of the transmission con
ella [17]

Complete Question:

A system has defined specifications that describe how signals are sent over connections. Which layer of the Transmission Control Protocol/Internet Protocol (TCP/IP) model provides this function?

Group of answer choices.

A. Transport

B. Network

C. Data link

D. Physical

Answer:

A. Transport

Explanation:

Transmission Control Protocol/Internet Protocol (TCP/IP) model is a standard communication protocol used for interconnecting network devices such as routers, switches, host computers and access points over the internet.

A system has defined specifications that describe how signals are sent over connections. The layer of the Transmission Control Protocol/Internet Protocol (TCP/IP) model that provides these functions is the transport layer.

The transport layer comprises of two (2) standard protocols and these are TCP and UDP.

TCP is an acronym for Transmission Control Protocol and it is one of the essential and important protocol of the internet protocol network. This simply means that, it is an essential part of the TCP/IP network. The TCP has a wide range of applications in the following areas, file transfers, world wide web, remote administration, e-mail, etc.

The TCP connection are mainly established in the network using the three-way handshake.

UDP is an acronym for user datagram protocol and it enables the transfer or exchange of data between network devices.

3 0
3 years ago
(15 POINTS) When an error is made in HTML code, the browser does what?
Rzqust [24]
Look up "List of HTTP status codes" in Wikipedia. It's important to know the error and this list show what possibilities exist.
7 0
3 years ago
Why is a DNS cache poisoning attack dangerous? Check all that apply. A. Errrr...it's not actually dangerous. B. It allows an att
larisa [96]

Answer:

(B) It allows an attacker to redirect targets to malicious webserver.

(D) It affects any clients querying the poisoned DNS server.

Explanation:

DNS cache poisoning is a serious type of attack that is designed to exploit the vulnerabilities inherent in a Domain Name Server (DNS) where a user is redirected from a real server to a fake one. It is also called DNS spoofing.

Normally, when your browser tries to visits a website through a given domain name, it goes through the DNS server. A DNS server maintains a list of domain names and their equivalent Internet Protocol addresses. This server (DNS) then responds to the request with one or more IP addresses for the browser to reach the website through the domain name.

The computer browser then get to the intended website through the IP address.

Now, if the DNS cache is poisoned, then it has a wrong entry for IP addresses. This might be via hacking or a physical access to the DNS server to modify the stored information on it. Therefore, rather than responding with the real IP address, the DNS replies with a wrong IP address which then redirects the user to an unreal website.

Although they might not be able to control your computer remotely as long as you are not trying to visit a web page via the poisoned information, there are other dangers attached to this type of attack.

Once the DNS server has been poisoned, any client trying to query the server will also be affected since there is no direct way of knowing if the information received from the server is actually correct.

4 0
3 years ago
Write a program that first gets a list of integers from input. The input begins with an integer indicating the number of integer
dalvyx [7]

Answer:

The program is as follows:

def output_ints_less_than_or_equal_to_threshold(user_values, upper_threshold):

   for i in user_values:

       if i <= upper_threshold:

           print(i,end=" ")

           

def get_user_values():

   user_values = []

   n = int(input())

   for i in range(n):

       num = int(input())

       user_values.append(num)

   

   upper_threshold = int(input())

   output_ints_less_than_or_equal_to_threshold(user_values, upper_threshold)

get_user_values()

Explanation:

This defines the output_ints_less_than_or_equal_to_threshold method

def output_ints_less_than_or_equal_to_threshold(user_values, upper_threshold):

This iterates through user_values

   for i in user_values:

For every item in user_values

       if i <= upper_threshold:

This prints all items less than or equal to the upper threshold

           print(i,end=" ")

           

This defines get_user_values method

def get_user_values():

This creates an empty list

   user_values = []

This gets the number of inputs

   n = int(input())

This iterates through n

   for i in range(n):

This gets input for every item of the list

       num = int(input())

This appends the input to the list

       user_values.append(num)

This gets input for upper threshold    

   upper_threshold = int(input())

This calls output_ints_less_than_or_equal_to_threshold method

   output_ints_less_than_or_equal_to_threshold(user_values, upper_threshold)

The main begins here; This calls get_user_values method

get_user_values()

4 0
3 years ago
Other questions:
  • Write a complete program to read two integers and display the number of integers that lie between them, including the integers t
    12·1 answer
  • When it comes to safety, the choice to be safe is often up to __________?
    8·1 answer
  • Pls help me!!!!!!!!!!!!!
    5·2 answers
  • Kyle asked his supervisor which type of computing model was used when the enterprise first started. She explained that the organ
    14·1 answer
  • Which snippet of code is in XML?
    5·1 answer
  • (3 points) Write a program to process two large chunks of data (e.g., a large 3D array and an array of self-defined structures w
    11·2 answers
  • How do i move a file in python3
    10·1 answer
  • What are two names for the database that holds digital signatures provided by os manufacturers, such as microsoft and red hat?
    6·1 answer
  • Why do people still use Intel HD graphics for gaming?
    8·1 answer
  • Aaaaaaaaaaaaaaaaplssssssssssssssssssssssssssssshelpppppppppppppppppppppppp
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!