hi everyone
i need help how to
-creates an array for 5 integers and store it in array
-use the highest & lowest integer and cube it
i stuck in array, i confuse how to input integers to array with JOptionPane
so far for the input
import javax.swing.*;
import java.text.DecimalFormat;
import java.util.Arrays;
public class WS06
{
public static void main (String[]args)
{
String numStr; int num=0;
int[] number = new int[5];
Arrays.sort(number);
int maximum=number[0];
do
{
numStr = JOptionPane.showInputDialog ("How many numbers do you want to enter"); //reprompt if the input is not integer
try
{
num = Integer.parseInt(numStr);
}
catch (NumberFormatException e)
{
JOptionPane.showInputDialog("How many numbers do you want to enter");
}
}
while (num <1 || num > 10);
for (int i = 0; i < number.length(); i++) // i get problem here <<<<<<<
{
number[i] = JOptionPane.showInputDialog("Enter a number between 1 and 100"); //store the input to array
}
for (int i=1; i<number.length; i++) //read trough the array and save the highest integer
{
if (number[i] > maximum)
{
maximum = number[i];
}
}
}
}