Generics enable you to specify the exact type that will be stored in a collection and give you the benefits of compile-time type checking—the compiler issues error messages if you use inappropriate types in your collections. Once you specify the type stored in a generic collection, any reference you retrieve from the collection will have that type. Instructions Write a program that inserts 25 random integers from 0 to 100 in order into Java’s LinkedList object (you must use Java’s LinkedList class to get any credit for this assignment). The program must: sort the elements, then calculate the sum of the elements, and calculate the floating-point average of the elements.
Generics enable you to specify the exact type that will be stored in a collection and give you the benefits of compile-time type checking—the compiler issues error messages if you use inappropriate types in your collections. Once you specify the type stored in a generic collection, any reference you retrieve from the collection will have that type.
Instructions
Write a
The program must:
- sort the elements,
- then calculate the sum of the elements, and
- calculate the floating-point average of the elements.
For this assignments make sure that your screen shot(s) show your program running and that your runtime display shows your random list, sorted list, sum of the elements, and average of the elements. You only get credit for what you demonstrate. Below is a sample screen shot. Your output doesn’t have to look exactly like this but you should display the unsorted list, the sorted list, the sum, and the average to get full credit.
Introduction
Java programming:
Java is cross-platform, meaning it can run on any operating system, and is relatively easy to learn. It is a versatile language that has powerful tools for creating efficient and secure applications. It is used in a variety of applications, from desktop applications to web development, mobile development, and embedded systems. Java is popular for its scalability and support for a wide range of libraries and tools.
To find:
Program that inserts 25 random integers from 0 to 100.
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images