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
kupik [55]
3 years ago
12

Write a program that inserts 25 random integers from 0 to 100 in order into a LinkedList object.The program must:• sort the elem

ents,• then calculate the sum of the elements, and• calculate the floating-point average of the elements.Utilizing Java htp 10 late objects approach
Computers and Technology
1 answer:
posledela3 years ago
4 0

Answer:

Written in Java

import java.util.Collections;

import java.util.Random;

import java.util.LinkedList;

class Main {

 public static void main(String[] args) {

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

   Random rand = new Random();

   int randnum;

   int sum = 0;

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

       randnum = rand.nextInt(101);

       myList.add(new Integer(randnum));    

       sum+=randnum;

   }

   Collections.sort(myList);

   System.out.println(myList);

   System.out.println("Average: "+(float)sum/25);

 }

}

Explanation:

import java.util.Collections;

import java.util.Random;

import java.util.LinkedList;

class Main {

 public static void main(String[] args) {

This declares a linkedlist as integer

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

This declares random variable rand

   Random rand = new Random();

This declares randnum as integer

   int randnum;

This declares and initializes sum to 0

   int sum = 0;

The following iteration generates random numbers, inserts them into the linkedlist and also calculates the sum of the generated numbers

<em>    for(int i = 0;i<25;i++)    { </em>

<em>        randnum = rand.nextInt(101); </em>

<em>        myList.add(new Integer(randnum));     </em>

<em>        sum+=randnum; </em>

<em>    } </em>

This sorts the list

   Collections.sort(myList);

This prints the list

   System.out.println(myList);

This calculates and prints a floating-point average

   System.out.println("Average: "+(float)sum/25);

 }

}

You might be interested in
Recall the binary search algorithm.1. Using the algorithm/algorithmic environment, give pseudocode using a for loop.AnswerMy alg
faust18 [17]

Answer:

Following are the Pseudo Code to the given question:

Explanation:

Following are the pseudo-code by using the For loop:

Defines the A function (node, element)

The node is larger than 0.

if another value of the node equals its element

Loop Break

That element if node. value becomes lower than that

Node is node equivalent.

right

Using other nodes is node equivalent.

 left

Node Return

If the node is vacant

print the Tree is empty

Following are the pseudo-code by using the while loop:

Defines the function A(node,element)

While this node is not zero.

if the value of the node equals the element

Loop Break

The element if node. value is lower than

Node is node equivalent.

right

Using other nodes is equivalent to an a.left node

Node Return

If the node is vacant

print Tree is empty

following are the Pseudo-code for recursion:

Set the function A (node, key)

If no root is the same as the root or no root.

return the root.

If the root value is lower than that of the quest for key return (root. right, key)

Return your lookup (root.left,key)

 

5 0
3 years ago
Data that are collected on large populations of individuals and stored in databases are referred to as _____.
xz_007 [3.2K]
The answer is statistics
4 0
3 years ago
Who know's web Design
balu736 [363]

Answer: B

Explanation:

inline is the answer

4 0
3 years ago
WHO WANTS TO PLAY AMONG US
Elza [17]

Answer:

Explanation:

ME

8 0
3 years ago
Read 2 more answers
Please answer fast! I need this now!
nexus9112 [7]

Answer:

The GDD (game design document) comprises of the three things. And the first thing is a description of the product, and which is explained in the question, and it is the gameplay. This part of the GDD mentioned in the question is the way the game is to be played, and what is the risk involved in the different stages of the game.

Explanation:

Please check the answer.

7 0
3 years ago
Other questions:
  • To print a budget:________.
    15·1 answer
  • Morgan's cursor is blinking in the center of the page but he would like to move it to the left margin. He should _____.
    10·1 answer
  • Suppose two hosts, A and B, are separated by 15,000 kilometers and are connected by a direct link of R = 5 Mbps. Suppose the pro
    11·1 answer
  • A manager in your company wants to standardize all mobile device applications across different operating systems. Some users hav
    10·1 answer
  • What kinds of online behaviors could be considered cyberbullying?
    7·2 answers
  • Hey hope you are having a great day. Please subscribe to me on You tube at (Resurgentz). :)
    13·1 answer
  • CODE EXAMPLE 3-1 SELECT vendorName, invoiceNumber, invoiceDate, invoiceTotal FROM vendors INNER JOIN invoices ON vendors .vendor
    13·1 answer
  • What do astronomers call a system that is composed of more than two stars?
    9·2 answers
  • The design of a blog refers to:
    8·1 answer
  • You are writing a program using the Java language. Which of the following is a requirement of Java syntax?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!