hi.....i have finished the program that determines if the students fails or not..according to the grades.....well....i have an error..i dont know how to overcome it...it says " class expexted...here is the code :
import java.util.Vector;
import javax.swing.JOptionpane;
import java.io.InputStreamReader;
import java.io.BufferedReader;
public class student
{
double mark[]= new double[5];
String grade;
string name;
int id;
Vector v=new Vector();
student()
{
grade="";
name="";
id=0;
for(int i=0; i<5; i++)
{
mark[i]=0;
}
}
student (double d[], String g, String n, int idno)
{
mark =d;
grade=g;
name=n;
id=idno;
}
public void menu()
{
int choice = Integer.parseInt(JOptionPane.showInputDialog (" Enter No. for the Operation"
+"\n 1. Add a student."
+"\n 2. Total number of student."
+"\n 3. No. of students falling."
+"\n 4. Generate an annual report."
+"\n 5. Continue."
+"\n 6. Exit."));
if (choice ==1)
{ getValues(); }
else if (choice==2)
{ getTotalNumber(); }
else if(choice==3)
{ getfallgrade();}
else if(choice==4)
{display();}
else if(choice==5)
{menu();}
else
{ System.exit(0); }
menu();
}
public void getValues()
{
student s=new student();
s.name = JOptionPane.showInputDialog("Input student name:");
String idno = JOptionPane.showInputDialog("Enter ID:");
s.id =Integer.parseInt(idno);
String m = JOptionPane.showInputDialog("Marks for Mathematics");
String m1 = JOptionPane.showInputDialog("Marks for Arts");
String m2 = JOptionPane.showInputDialog("Marks for Science");
String m3 = JOptionPane.showInputDialog("Marks for Games");
String m4 = JOptionPane.showInputDialog("Marks for Computers");
s.mark[0]= double.parseDouble(m);
s.mark[1]= double.parseDouble(m1);
s.mark[2]= double.parseDouble(m2);
s.mark[3]= double.parseDouble(m3);
s.mark[4]= double.parseDouble(m4);
v.add(s);
}
public void getmark()
{
for (int i=0; i<5; i++)
{
System.out.println(mark[i]);
}
}
public void getfallgrade()
{
int acount=0;
int bcount=0;
int ccount=0;
int dcount=0;
int fcount=0;
for (int i=0; i<v.size(); i++)
{
student s = (student) v.elementAt(i);
if(s.grade=='A')
acount++;
else if(s.grade=='B')
bcount++;
else if(s.grade=='c')
ccount++;
else if(s.grade=='D')
dcount++;
}
System.out.println("students under A:"+acount);
System.out.println("students under B:"+bcount);
System.out.println("students under C:"+ccount);
System.out.println("students under D:"+dcount);
System.out.println("students under F:"+fcount);
}
public void getgrade()
{
double sum=0, avg=0;
for (int j=0; j<5; j++)
{
sum+= mark[j];
}
avg=sum/5;
System.out.println(avg);
if(avg>=90) grade="A";
else if (avg>=80) grade ="B";
else if (avg>=70) grade ="C";
else if (avg>=60) grade ="D";
else grade="F";
System.out.println(grade);
}
void getTotalNumber()
{
System.out.println( "Total number of students =" + v.size());
}
public void getname()
{
System.out.println(name);
}
public void getid()
{
System.out.println("ID:"+id);
}
void display()
{
for (int i=0; i<v.size(); i++)
{
student s =(sudent) v.elementAt(i);
System.out.println("Marks for students");
s.getmark();
s.getgrade();
s.getname();
s.getid();
}
}
public static void main( String args[]) throws Exception
{
student s = new student();
s.menu();
}
}
the error i get is in this part :
s.mark[0]= double.parseDouble(m);
^
s.mark[1]= double.parseDouble(m1);
^
s.mark[2]= double.parseDouble(m2);
^
s.mark[3]= double.parseDouble(m3);
^
s.mark[4]= double.parseDouble(m4);
^
thannks