@GeorgeGibby/

Mean, Median, and Mode

Java

Discrete math is tedious, so I made it less tedious.

fork
loading
Files
  • Main.java
  • Main.class
Main.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import java.util.Scanner;
class Main 
{
  public static void main(String[] args) 
  {
    int mean;
    int median;
    int mode;
    int length;

    Scanner reader = new Scanner(System.in);

    System.out.println("Number of data elements: ");
    length = reader.nextInt();
    int[] data = new int[length];
    System.out.println("Data: ");
    for(int i = 0; i < length; i++)
    {
      data[i] = reader.nextInt();
    }
    for(int i = 0; i < data.length; i++)
    {
      int temp;
      int index;
      for(int j = data.length - 1; j > 0; j--)
      {
        index = data[j];
        if(data[j] > data[j-1])
          index = j;
      }
        
    }
    for(int x : data)
    {
      System.out.print(x + " ");
    }
  }
}