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
Elenna [48]
3 years ago
9

Create a list with 5 numbers and find the smallest and largest number in the list and also the sum and product of the numbers in

the list, Additionally, find the sum and product of the largest and the smallest number.
Computers and Technology
1 answer:
rusak2 [61]3 years ago
6 0

Answer:

Explanation:

The following code is written in Java. It creates 5 random integers and saves them to a list called myList. Then it loops through that list and checks each one until the largest and smallest values are obtained. Finally, it uses these values to calculate the sums and products as requested. The program has been tested and the output can be seen in the attached image below.

import java.util.ArrayList;

import java.util.Arrays;

import java.util.Random;

import java.util.Scanner;

class Brainly {

   public static void main(String[] args) {

       Random rand = new Random();

       ArrayList<Integer> myList = new ArrayList<>();

       for (int i = 0; i< 5; i++) {

           int mynum = rand.nextInt(20);

           myList.add(mynum);

       }

       int largest = myList.get(0);

       int smallest = myList.get(0);

       int sum = 0;

       int product = 1;

       int sumLargestandSmallest, productLargestandSmallest;

       for (int x : myList) {

           if (x > largest) {

               largest = x;

           }

           if (x < smallest) {

               smallest = x;

           }

           sum += x;

           product *= x;

       }

       sumLargestandSmallest = largest + smallest;

       productLargestandSmallest = largest * smallest;

       System.out.println("List" + Arrays.toString(myList.toArray()));

       System.out.println("Smallest: " + smallest);

       System.out.println("Largest: " + largest);

       System.out.println("Sum: " + sum);

       System.out.println("Product: " + product);

       System.out.println("Sum of Smallest and Largest: " + sumLargestandSmallest);

       System.out.println("Product of Smallest and Largest: " + productLargestandSmallest);

   }

}

You might be interested in
Traffic that is encrypted will typically pass by an intrusion prevention system untouched.a. Trueb. False
Sauron [17]

Answer:

A. True

Explanation:

Data encryption is a technique that converts clear text into unreadable text and transmitted over a network, to prevent attackers from understanding the information send to the receiver, which can only be deciphered by the receiver and the sender with special keys or software.

An intrusion prevention system is used to mitigate cyber attackers by preventing unwanted packets that could be malicious, from entering the network.

The intrusion prevention system can only see clear text data. For this reason, an encrypted text can pass through the prevention system untouched.

3 0
3 years ago
Desirable workplace habits and skills include:
levacccp [35]
Being extroverted
Problem-Solving
6 0
3 years ago
What is a Computer ?and it's demerits​
kherson [118]

Answer:

Computer has making human life faster because of its incredible speed,Accuracy and storage, with which human can save anything and search it out easily when needed. We can say computer a versatile machine because it is very flexible in performing their jobs.

6 0
3 years ago
Read 2 more answers
How can i appear offline without fb messenger saying "last active 1 minute ago"?
Furkat [3]
Go to settings and hit privacy to change who can see your posts
5 0
3 years ago
MegaCorp MegaCorp is large manufacturing firm that operates 5 factories in Dallas, 4 factories in Los Angeles, and 5 factories i
Ivenika [448]

Answer:

Recommended is frame relay architecture with a local loop at each factory supporting the frame relay service connection to the network provider's POP

Explanation:

Frame Relay can be seen as WAN protocol that is said to often operate at both the physical and data layers link of the OSI reference model due to it high-performance and due to the fact that FRAME RELAY are as well use across Integrated Services Digital Network (ISDN) interfaces in which they are designed for cost-efficient data transmission in order to enable effective intermittent traffic between local area networks (LANs) and endpoints in wide area networks (WANs) which is why frame contains all the information necessary to route it to the correct destination.

Therefore type of BN and WAN architecture and WAN service i would recommend based on the above information is FRAME RELAY ARCHITECTURE with a local loop at each factory supporting the frame relay service connection to the network provider's POP.

8 0
3 years ago
Other questions:
  • Behaving in an acceptable manner in a workplace environment is referred to as workplace etiquette.
    12·2 answers
  • Which of the following is not part of active listening?
    6·2 answers
  • What is the best way to locate where my C program gets into an infinite loop
    5·1 answer
  • (Convert milliseconds to hours, minutes, and seconds) Write a function that converts milliseconds to hours, minutes, and seconds
    12·1 answer
  • What does remedy mean
    7·2 answers
  • What are the two basic classes of active directory objects?
    14·1 answer
  • The add_prices function returns the total price of all of the groceries in the dictionary. Fill in the blanks to complete this f
    15·1 answer
  • Ian kno da answer tell me
    7·2 answers
  • In this exercise, you will get some practice with the __add__ method by implementing it for a class called ContactBook. This cla
    12·1 answer
  • What is your impression on the subject fundamentals of database systems?​
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!