The project is to do a grade averaging program in a loop using JOptionPane.
Bellow is the errors I am getting, does int[] array = new int[numberOfGradesString]; have to be defined like int[] array = new int[100];?
Because I have seen examples that compiled Java: Arrays
Thank you for the help.
import javax.swing.*; public class Project2TestEdit1 { public static void main( String[] args ) { //...Varibles declared for whole program. String numberOfGradesString, gradeString; int average, sumOfGrades, selection; int numberOfGrades = 1; double quotient; boolean runAgain = true; //...Loop do{ //...Enter a Grade to be averaged for each iteration of the loop. gradeString = JOptionPane.showInputDialog( "Enter a grade to be averaged." ); //...Asks if you want to run anouther. selection = JOptionPane.showConfirmDialog(null, "Would you like to run another?","Confirmation", JOptionPane.YES_NO_OPTION); //...Runs loop again if option YES is selected. runAgain = (selection == JOptionPane.YES_OPTION); //...Adds anouther place value to the array increment each iteration of the loop. numberOfGrades = numberOfGrades++; //...Continues the loop. }while (runAgain); //...The array, each iteration of the loop a place value is added with the grade intered as the value. int[] array = new int[numberOfGradesString {gradeString}]; //...Avergaing formula. sumOfGrades = numberOfGrades + gradeString; average = (sumOfGrades / numberOfGrades); //... JOptionPane.showMessageDialog(null, average + " Is the Average" ); System.exit(0); //...Ends the window. } } ERRORS ----jGRASP exec: javac -g C:\Documents and Settings\jeremy\Desktop\SCHOOL\CMIS 141\week 7\Project2TestEdit1.java Project2TestEdit1.java:45: incompatible types found : java.lang.String required: int int[] array = new int[numberOfGradesString]; ^ Project2TestEdit1.java:49: incompatible types found : java.lang.String required: int sumOfGrades = numberOfGrades + gradeString; ^ 2 errors ----jGRASP wedge2: exit code for process is 1. ----jGRASP: operation complete.