Hi and thanks in advanced.
this is my first attempt at java and im having trouble because i want to do things like in C++.
ok i simply would like to create a program that will ask the user to enter a number of grades to be averaged. Store that number in a variable. Insert the veriable number in an array ( to set size ). Then promt the user to enter the gpa's to be averaged and save them in the array. heres my code so far.
i dont know enough java to know why this error is here, this is the errorCode:import javax.swing.*; import java.text.*; public class average { public static void main(String args[]) { String input; int a = 0; int c = 1; double b = 0; input = JOptionPane.showInputDialog("Please enter the number of grades to enter"); a = Integer.parseInt(input); double[] average; average = new double[a]; while(c <= a) { average[b] = JOptionPane.showInputDialog("Enter gpa #" + c); // <---------ERROR HERE c =c+1; } //more to come here System.exit(0); } }
lol i hope any1 can help. again thanks in advanced and god blessCode:C:\java>javac average.java average.java:22: possible loss of precision found : double required: int average[b] = JOptionPane.showInputDialog("Enter gpa #" + c); ^ average.java:22: incompatible types found : java.lang.String required: double average[b] = JOptionPane.showInputDialog("Enter gpa #" + c); ^ 2 errors
g.g.
[ArchAngel added CODE tags]


Reply With Quote



Bookmarks