Mathematical statistics


Wednesday, October 25, 2023 Difficulty: Intermediate

Objective

Create a Java program for generating mathematical statistics. The program should store a total of 1000 decimal numeric values in a data array and provide a menu with various user-selectable options. It will run until the user selects the exit option. The program menu should include the following options (1-5):

  • Add
  • View
  • Search
  • Statistics
  • Exit

Functionalities:

  1. Add: In this option, users can add new values to the data array. Ensure not to exceed 1000 values.
  2. View: The "View" option displays the list of values in a single line. There may be no values yet.
  3. Search: To search for values, the program will request a real number from the user and determine its existence in the program. There may be no values yet.
  4. Statistics: In this option, the program provides the user with a summary of statistics for the values in the data array, including:
    • The total stored values.
    • Total sum of values.
    • Arithmetic mean.
    • Maximum and minimum values.
  5. Exit: To terminate the program.

Input

1. Add
2. Show
3. Search
4. Statistics
5. Exit
Enter a option (1-5): 1
7

1. Add
2. Show
3. Search
4. Statistics
5. Exit
Enter a option (1-5): 2

1. Add
2. Show
3. Search
4. Statistics
5. Exit
Enter a option (1-5): 3
6

1. Add
2. Show
3. Search
4. Statistics
5. Exit
Enter a option (1-5): 4

1. Add
2. Show
3. Search
4. Statistics
5. Exit
Enter a option (1-5): 5

Output

7
Not found
Total data: 1
Sum: 7
Average: 7
Min value: 7 
Max value: 7

Solution

Click here to view the exercise solution

Share it

Share it on your social media and challenge your friends to solve programming problems. Together, we can learn and grow.

Copied

The code has been successfully copied to the clipboard.

More Exercises

Continue improving your Java programming skills with our selection of practical exercises from the lesson. Click on Practice and challenge your knowledge!

1

Reverse order array

Create a Java program that prompts the user for 5 integers to store them in an integer array and displays them in reverse order.

2

Search an array of integers

Create a program in Java that serves to search an array of integer values.

3

Search even numbers

Write a Java program that prompts the user to enter 10 integers. Then, store these numbers in an integer array and display only the even numbers.

4

Search positive and negative numbers

Write a Java program that prompts the user to enter 10 real numbers and displays the arithmetic mean of positive and negative numbers.

5

Banner command on Unix

Create a Java program that mimics the functionality of the banner command on Unix.

6

Bubble sort

Create a Java program that prompts the user for 10 integers and sorts them using the bubble sort algorithm.

7

Two-dimensional array

Create a Java program that prompts the user to input the scores of 10 students, divided into 2 groups of 5 students each.

8

Two-dimensional array of chars

Create a Java program that declares a two-dimensional character array of 20 rows by 70 columns and stores the letter 'X' to display on the screen.

9

Mathematical statistics

Java Program for Mathematical Statistics: Store, Analyze, and Visualize Data. Enhance Your Skills!

10

On-screen circumference

Create a Java program that draws a 360 screen circumference.

Arrays

Practice with exercises in Java that use arrays of different dimensions to store the information.

Practice exercises

Keep learning

C# Programming Course

Free programming course with practical exercises and solutions in C#. Start learning right now!

Exercises C# App

Take your Exercises C# lessons everywhere with our Android app. Download it now from Google Play