Hey everyone, I am writing a program that requires me to use an array to find the mode of 10 numbers. I have working except I want it to just print the mode, but it keeps printing every number I enter. Any suggestions? Thanks in advance.
import TerminalIO.KeyboardReader;
public class mode
{
public static void main(String[] args)
{
KeyboardReader reader = new KeyboardReader();
double [] num = new double[10];
double [] mod = new double[10];
double number;
double mode;
for(int i = 0; i < 10; i++)
{
System.out.println("Please Enter Your Numbers: ");
number = reader.readDouble();
num[i] = number;
}
for(int a = 0; a < 10; a++)
{
for(int j = 0; j < 1000; j++)
{
if(num[a] == j)
{
mode = num[a];
System.out.print(mode+" ");
}
}
}
}
}