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
Uhaul general mechanical questions 2021
hammer [34]

Moving or transportation tools, equipment and methods provides guidance

on the safe an efficient ways to move items.

The correct responses are;

1) (B); 2) B; 3) C; 4) A; 5) D; 6) B; 7) A; 8) B; 9) (A); 10) A; 11) C; 12) B; 13) A; 14) A; 15) B; 16) A; 17) B; 18) A; 19) (C); 20) B; 21) B; 22) A; 23) B; 24) (C); 25) B

Reasons:

1) The correct option is; (B) Withstand a heavier load and add greater stability

  • By sing two wheels on the rear of a truck, heavy loads can be hauled, and transported around corners, and bumpy roads, reducing the possibility of the load tipping the truck over, thereby keeping the truck stable.

2) The correct option is; B

  • The Phillips-head screw is cross shaped, and required a cross shaped screwdriver, which is option B)

3) The correct option is; C

  • The alternator converts mechanical rotational energy into electrical energy, and usually has a compact electrical coil and magnets within its enclosure. The alternator is option C

4) The correct option is; A

  • The rear of a truck moves in the direction the front tires are turned

5) The correct option is; D

  • Option A  and B are pliers, while option B is a spanner, all of which are used to fasten and loosen bolts and nuts. Option D is a screwdriver used to fasten and loosen screws.

6) The correct option is; B

  • The working platform on scaffold B has extra support from the diagonal braces.

7) The correct option is; A

  • The large size tires in refrigerator A increases the contact surface with the road to prevent entering into small holes

8) The correct option is; B

  • Due to the heavier load in the trailer of pick-up truck B, more force is required, to stop the truck according to Newton's Laws of motion, and therefore, a longer distance will be taken to stop by the truck, given similar conditions (magnitude) stopping force available

9) The correct option is; (A)

  • Jumping two batteries to start an automotive with a dead battery requires a Negative to Negative / Positive to Positive  connection, which is option (A)

10) The correct option is; A

  • The air filter will have a open outer rim for the free passage of air.

11) The correct option is; C

  • The scale measures the difference in weight, and the weight depends on the mass of the item. Given that the mass are equal, both weights would be equal, and therefore, the scale would be level.

12) The correct option is; B

  • The smoothest ride is closest to the most weight of the vehicle, which is located in the front, therefore, the area that gets the smoothest ride is option B

13) The correct option is; A

  • The downward pressure is given by the location of the load relative to the wheel on the trailer, that gives either a clockwise or downward moment of force when in position of option A or a counterclockwise or upward moment at B

14) The correct option is; A

  • Gear connected by belt or chain move in the same direction, therefore, the direction of wheel 3 is option A

15) The correct option is; B

  • A tire blowout will not occur because, the pressure is below the recommended pressure. However, the motion of the car will be unstable

16) The correct option is; A

  • When tightening a nut with an adjustable wrench, the direction of turning the wrench is towards the movable jaw, therefore, the option A is correct

17) The correct option is; B

  • The difference between the threads of the given tires is the depth of their grooves, therefore, the tire in option B has more thread.

18) The correct option is; A

  • When loading items on a trailer, the majority of the load should be located in the front, therefore, the correct location for loading only the washer is illustrated by the picture A.

19) The correct option is; (C)

  • The object has a lead, an insulated handle, and a electrical bulb that lights up when there is electricity, therefore, it is used for (C) Checking for electrical current travelling through a wire.

20) The correct option is; B

  • The trailer swings in the opposite direction to the truck.

21) The correct option is; B

  • The ladder in picture B is safer because it spreads more at the base

22) The correct option is; A

  • Most of the weight of the refrigerator act on the wheel in picture A than in picture B

23) The correct option is; B

  • The gear turns towards the screen on the left and away from the screen on the right, which is a direction from left to right.

24) The correct option is; (C)

  • The cotter pin is assembled last to hold the bolt in place, and cannot be assembled before the other parts as it will restrict their movement

25) The correct option is; B

The front tire should be turned in the opposite direction to the intended direction of the trailer.

Learn more here:

brainly.com/question/69628

6 0
3 years ago
This is a free point thing!! I am giving 100 points!! Anyone wanna talk!!!!
julia-pushkina [17]

Answer:

:)

Explanation:

8 0
3 years ago
Read 2 more answers
Which of the following statements is FALSE?
irina1246 [14]

Answer:

d. Should be lower case?

7 0
3 years ago
Interest assessments are always accurate. True False
Brums [2.3K]

Answer:

False

Explanation:

3 0
3 years ago
Which statement best describes the difference between a spreadsheet and a database?
Dmitrij [34]

Answer:

Databases store data in tables that interact; spreadsheets store data in cells that interact.

Explanation:

3 0
3 years ago
Read 2 more answers
Other questions:
  • manufacturers are making an effort to build energy-efficient computers and use recyclable cases and packaging true or false
    10·1 answer
  • Plz answer me will mark as brainliest ​
    7·2 answers
  • What is TRUE about the following array?
    15·1 answer
  • When Liam went to print his presentation, the boot process established the connection to the printer, sent the presentation to t
    12·1 answer
  • On a piano, a key has a frequency, say f0. Each higher key (black or white) has a frequency of f0 * r^n, where n is the distance
    10·1 answer
  • Which of the following statements about email is true?
    5·1 answer
  • What will the value of x be after the following statements execute? int x = 0; int y = 5; int z = 4; x = y z * 2;
    14·1 answer
  • Produce definition in computer
    9·2 answers
  • What is the component on the motherboard that confirms all devices are in working order once the computer is turned on?
    13·1 answer
  • Which of the following correctly declares and initializes a Scanner object that will use input from the keyboard as its data sou
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!