ah damn, i get ya, thanks for that CaptinMorgan.
i knew it was going to be something simple! the array works nicely with no problms, however for some reason it only displays "0" as the highest value in the array...
the program is as follows:
//Program's objective is to display the maximum value,
//entered in an array
import javax.swing.*;
public class eightA
{
public static void main(String[] args)
{
final int NUMELS=6;
int i, max;
int fmax[] = new int[NUMELS];
max = fmax[0];
String s1;
for (i = 1; i < fmax.length - 1; i++)
{
s1 = JOptionPane.showInputDialog("Enter a number: ");
fmax[i] = Integer.parseInt(s1);
}
if (max < fmax[i])
max = fmax[i];
JOptionPane.showMessageDialog(null, "The maximum value is " + max , "message",
JOptionPane.INFORMATION_MESSAGE);
}
}
i dont see why it cannot work, ive done this exact same one before using manualy entered elements in the array and terminal rather then gui...
there's that program, mabey i did something wrong when i changed it to GUI?
public class FindMaxValue
{
public static void main(String[] args)
{
int i, max;
int fmax[] = {2, 18, 1, 27, 16};
max = fmax[0];
for (i = 1; i < fmax.length; i++)
if (max < fmax[i])
max = fmax[i];
System.out.println("The maximum value is " + max);
}
}
one final question...how would i go about displaying the element's numbered location aswell