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
Users report that the database on the main server cannot be accessed. A database administrator verifies the issue and notices th
navik [9.2K]

Answer: (C) Ransomware

Explanation:

The ransomware is one of the type of malware software design which is used for blocking the user accessing unauthorized and also without paying money.

The most of the ransomware software encrypt the computer accessing and the files as they demand for the payment dues for again restoring the access.  

It also encrypt the user account and the information until the correct decrypt key are get entered into the system. So, according to the given situation, the ransomware attack are experienced in an organization.  

Therefore, Option (C) is correct.

4 0
3 years ago
Int [] val = { 3, 10, 44 };
Shtirlitz [24]

Answer:

4) 3 11 44

Explanation:

Given data

int [] val = { 3, 10, 44 };

The total number of parameters of given array are 3, so total length of array is also 3.

The indexing of array starts with '0', Therefore the indexes of array with length zero are: {0,1,2}

The value of array at index 0 is = 3

similarly,

value at index 1 = 10

value at index 2 = 44

Here, Int i = 1 is storing the value '1' in integer variable i.

In addition to that, any value of index 'i' of an array is selected using array[i].

Therefore,

val[i] is selecting the value of array located at index '1' because i = 1.

val[i] = val[1] = 10

val[i]+1 is selecting the value of array located at index 'i' that is (1) and adding 1 to it

=> val[i] = 10

=> val[i]+1 = 10+1 = 11

Finally,

val[i] = val[i]+1; is copying the val[i]+1 = 11 to value placed at index 1 (10). Hence, the output would be {3 11 44}. So 4th option is correct.

6 0
3 years ago
Write a program using integers userNum and x as input, and output userNum divided by x three times.
andrezito [222]

Answer:

# The user is prompted to enter number as dividend

# The received number is assigned to userNum

userNum = int(input("Enter the number you want to divide: "))

# The user is prompted to enter number as divisor

# The divisor is assigned to x

x = int(input("Enter the number of times to divide: "))

# divideNumber function is defined to do the division

def divideNumber(userNum, x):

   # counter is declared to control the loop

   counter = 1

   # the while-loop loop 3 times

   # the division is done 3 times

   while counter <= 3:

       # integer division is done

       # truncating the remainder part

       userNum = userNum // x

       # the result of the division is printed

       print(userNum, end=" ")

       # the counter is incremented

       counter += 1

# the divideNumber function is called

# the received input is passed as parameter

# to the function

divideNumber(userNum, x)

# empty line is printed

print("\n")

Explanation:

The // operator in python works like the / operator in C. The // operator returns only the integer part of division operation. For instance 6 // 4 = 1. The fraction part is discarded.

7 0
3 years ago
What password did the boss gave to the man?
lapo4ka [179]

Answer:

1947

Explanation:

because i dont know

7 0
3 years ago
Read 2 more answers
Why when i want to answer a profile that starts with a will put a link to "https://bitly.com/"
vodomira [7]
I don’t know i checked it and i think it’s a virus or something like that don’t click on link
6 0
3 years ago
Other questions:
  • You have just been named Director of Data Administration of General Hardware Co. General Hardware maintains a large central IS o
    15·1 answer
  • The java class library interface queue method tagg retrieves the entey at the front of a queue but themrows a NosuchElementExcep
    6·1 answer
  • This toolbar has icons representing the application's basic operations such as Save and Copy. Drawing Formatting Standard Task
    11·2 answers
  • Which of the following things would you access from the Program &amp; Courses page? Course descriptions Tutorial videos Account
    7·1 answer
  • Pls Help Me!!!!!!!!!!! It won’t work when I connect to ITunes!
    12·1 answer
  • 5. The coordinates of triangle ABC are A(-7, 3), B(3, -7) and C(8. 8)
    9·2 answers
  • As in algebra, you can use brackets to override the order of operations Excel follows to perform formula calculations. True or f
    13·1 answer
  • What is the name of the newer communication protocol that is supported by Window 10's version of TCP/IP?
    11·1 answer
  • Different computer applications and their uses.
    8·1 answer
  • Landing pages in a foreign language should never be rated fully meets?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!