Hey everyone the program I am writing has to find the mode, max, and median from an array. I think I have everything except there is one error I cannot figure out, thanks in advance.
import TerminalIO.KeyboardReader;
public class med
{
public static int MAX(int[] a)
{
int MAX = -99;
for(int t = 0; t< 10; t++)
if(a[t] > MAX)
MAX = a[t];
return MAX;
}
public static void main(String[] args)
{
KeyboardReader reader = new KeyboardReader();
int [] num = new int[10];
int [] fin = new int[10];
int numb = 0;
// int count;
// int big;
// int med;
// int mode;
int max = -1;
int min = -1;
for(int i = 0; i < 10; i++)
{
System.out.println("Please Enter Your Numbers: ");
numb = reader.readInt();
num[i] = numb;
}
for(int a = 0; a < 10; a++)
{
for(int j = 0; j < 10; j++)
{
if(num[a] == num[j])
fin[a]++;
max=MAX(fin);
for(int g = 0; g < 10; g++)
{
if(max==fin[g])
min=g;
}
int big = max(num);
System.out.print(num[min]+ "is the mode");
System.out.print("The max is: "+big);
int med;
med = num[5] + num[6];
med = med/2;
System.out.print(med+ "is median.");
}
}
}
}
The error is on line 42, it is pointing at "max" saying "cannot resolve symbol"