what you mean by use a loop and add anew object to the array?
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
what you mean by use a loop and add anew object to the array?
That was the answer to this:
How do i go about to initialize the array with students
If you don't understand my answer, don't ignore it, ask a question.
As of your code pasted in post#24:
line24: The method initialization(String[], double[], double[], double[], double[]) in the type S10122534c_Assignment is not applicable for the arguments (String[], double[], double[], double[])
...you are not sending the method what it expects to get. The method takes in first a String[] followed by four double[]. You are sending a String[] and only three double[] now. Look that over one more time and see what has been left out. Or maybe you don't need four double[] in the method. Maybe you do...
line44: namer cannot be resolved to a variable
...you have a parameter named "name", perhaps you just accidently put the letter 'r' on the end of your variable name by mistake on this line?
Try to resolve those two errors and post your code again. Good job on the code tags too btw.. Much easier on my 88 year old eyes...
Im getting an error which says the following file is missing class or inner class file..
What is this?
Please post the full text of any error messages you get.
If you don't understand my answer, don't ignore it, ask a question.
shadz92, Norm is offering valid advice, but the stream of conversation you two are involved in is a step beyond where your code is. I suggest you tackle the 24+ syntax errors first. ...just my opinion
i dun understand what i must do for the line 24???
This is the edited version
/*================================================================================== * FSP 2012 Assignment * Student ID : S10122534C * Student Name : Leonard Laura Rachel M * Module Group : FI05 * * ==================================================================================*/ import java.util.Scanner; public class S10122534c_Assignment { public static void main(String[] args) { final int MAXSIZE = 50; // maximum number of students String[] name = new String[MAXSIZE]; // array to store the names of the students double[] caMark = new double[MAXSIZE]; // array to store the Continuous Assessment marks double[] ctMark = new double[MAXSIZE]; // array to store the Common Test marks double[] asgMark = new double[MAXSIZE]; // array to store the Assignment marks double[] finalMark = new double [MAXSIZE]; // array to store the Final marks int count = 0; Scanner input = new Scanner(System.in); // initialize the array with students count = initialization(name,double[] caMark,double[] ctMark,double[] asgMark); int choice; finalMark = calculateFinalMark(count,caMark, ctMark, asgMark); do { choice = input.nextInt(); switch (choice) { case 1: displayStudentResults(name, caMark, ctMark, asgMark, finalMark, count);break; case 2: diplayFailedStudents(name, caMark, ctMark, asgMark, finalMark, count);break; case 3: addNewStudent(count);break; case 4: updateMarks(asgMark, count);break; case 5: exit();break; default:System.out.print("Thank you."); } }while (choice != 0); } // method to initialize the arrays with students public static int initialization(String[] name, double[] caMark, double[] ctMark, double[] asgMark, double[] finalMark) { name [0] = "Agnes Tan"; caMark [0] = 75; ctMark [0] = 68; asgMark [0] = 82; name [1] = "Benny Ong"; caMark [1] = 66; ctMark [1] = 30; asgMark [1] = 35; name [2] = "Denise Ng"; caMark[2] = 55; ctMark [2] = 42; asgMark [2] = 50; name [3] = "Jimmy Tay"; caMark [3] = 80; ctMark [3] = 76; asgMark[3] = 82; name [4] = "Evelyn Low"; caMark [4] = 70; ctMark [4] = 60; asgMark [4] = 65; return 5; } public static void displayMenue() { String[] nameArr; double[] caMarkArr; double[] ctMarkArr; double[] asgMarkArr; double[] finalMarkArr; { System.out.println ("MENU"); System.out.println ("========================================"); System.out.println (" [1]. Display the results of all students"); System.out.println (" [2]. Display the students who have failed"); System.out.println (" [3]. Add a new student"); System.out.println (" [4]. Update assignment mark of a student"); System.out.println (" [0]. Exit"); System.out.println ("Enter your option: _____ "); System.out.println ("========================================="); } } public static void displayStudentResults(String[] nameArr, double[] caMarkArr, double[] ctMarkArr, double[] asgMarkArr, double[] finalMarkArr) { int [] numArr = new int[50]; System.out.println("Student Name" + "CA" + "CT" + "ASG" + "FINAL" + "GRADE"); for (int i=0; i<numArr.length; i++) { System.out.println(nameArr[i] + caMarkArr[i] + ctMarkArr[i] + asgMarkArr[i] + finalMarkArr[i]); numArr[i]=i+1; } } //Calculate Final marks to compute whether the student has passed & to know the grades public static double calculateFinalMarks(int count, double[] caMark, double[] ctMark, double[] asgMark) { int a = count; finalMark = (0.4 * caMark[a]) + (0.3 * ctMark[a]) + (0.3 * asgMark[a]); System.out.print(finalMark); count++; return finalMark; } public static void displayFailedStudents (String[] name, double[] caMark, double[] ctMark, double[] asgMark, doubl[] finalMark) { System.out.println("No" + "Student Name" + "CA" + "CT" + "ASG" + "FINAL" + "GRADE"); for (int l=0; l<count; l++) { if (finalMark < 50) System.out.print(name[l], caMark[l], ctMark[l], asgMark[l], finalMark[l]); } } public static void addNewStudent(int count) { System.out.println("Option 3: Add New Student"); System.out.println("Enter Student Name: "); String name = input.next(); System.out.println("Enter CA Marks: "); double caMarks = input.nextDouble(); System.out.println("Enter CT Marks: "); double ctMarks = input.nextDouble(); System.out.println("Enter ASG Marks: "); double asgMarks = input.nextDouble(); System.out.println("One Student Added."); count++; } public static void updateMarks(int count, double asgMark) { int i = count; System.out.println("Option 4: Update Assignment Mark of a Student: "); System.out.println("Enter the serial number of the student to update : "); i = input.nextInt(); System.out.println("Enter new assignment mark : "); double asgMark = input.nextDouble(); System.out.println("The assignment mark is updated. "); asgMark[count-1] = asgMarks; } public static char gradeMark( double finalMark) { char gradeMark = 0; if (finalMark >=80) System.out.println("Grade A"); if ((finalMark >=70) && (finalMark < 80)) System.out.println("Grade B"); if ((finalMark >=60) && (finalMark < 70)) System.out.println("Grade C"); if ((finalMark >= 50) && (finalMark < 60)) System.out.println("Grade D"); if (finalMark < 50) System.out.println("Grade F"); return gradeMark; } }
As Norm pointed out, you wrote:You do not need to actually write "double[]" before your variable names when you use the method.count = initialization(name,double[] caMark,double[] ctMark,double[] asgMark);
The second problem on this line is that you are not supplying the five parameters the method wants. According to the method signature, you are leaving out one parameter. There is one type double[] missing.
this are the errors
S10122534c_Assignment.java:24: '.class' expected
count = initialization(name,double[] caMark,double[] ctMark,double[] asgMark);
^
S10122534c_Assignment.java:24: ';' expected
count = initialization(name,double[] caMark,double[] ctMark,double[] asgMark);
^
S10122534c_Assignment.java:24: <identifier> expected
count = initialization(name,double[] caMark,double[] ctMark,double[] asgMark);
^
S10122534c_Assignment.java:24: ';' expected
count = initialization(name,double[] caMark,double[] ctMark,double[] asgMark);
^
4 errors
Did you see post #25? On the last line It says how to fix one of the errors.
If you don't understand my answer, don't ignore it, ask a question.
/*================================================================================== * FSP 2012 Assignment * Student ID : S10122534C * Student Name : Leonard Laura Rachel M * Module Group : FI05 * * ==================================================================================*/ import java.util.Scanner; public class S10122534c_Assignment { public static void main(String[] args) { final int MAXSIZE = 50; // maximum number of students String[] name = new String[MAXSIZE]; // array to store the names of the students double[] caMark = new double[MAXSIZE]; // array to store the Continuous Assessment marks double[] ctMark = new double[MAXSIZE]; // array to store the Common Test marks double[] asgMark = new double[MAXSIZE]; // array to store the Assignment marks double[] finalMark = new double [MAXSIZE]; // array to store the Final marks int count = 0; Scanner input = new Scanner(System.in); // initialize the array with students count = initialization(name, caMark, ctMark, asgMark); int choice; finalMark = calculateFinalMark(count,caMark, ctMark, asgMark); do { choice = input.nextInt(); switch (choice) { case 1: displayStudentResults(name, caMark, ctMark, asgMark, finalMark, count);break; case 2: diplayFailedStudents(name, caMark, ctMark, asgMark, finalMark, count);break; case 3: addNewStudent(count);break; case 4: updateMarks(asgMark, count);break; case 5: exit();break; default:System.out.print("Thank you."); } }while (choice != 0); } // method to initialize the arrays with students public static int initialization( name, caMark, ctMark, asgMark, finalMark) { name [0] = "Agnes Tan"; caMark [0] = 75; ctMark [0] = 68; asgMark [0] = 82; name [1] = "Benny Ong"; caMark [1] = 66; ctMark [1] = 30; asgMark [1] = 35; name [2] = "Denise Ng"; caMark[2] = 55; ctMark [2] = 42; asgMark [2] = 50; name [3] = "Jimmy Tay"; caMark [3] = 80; ctMark [3] = 76; asgMark[3] = 82; name [4] = "Evelyn Low"; caMark [4] = 70; ctMark [4] = 60; asgMark [4] = 65; return 5; } public static void displayMenue() { String[] nameArr; double[] caMarkArr; double[] ctMarkArr; double[] asgMarkArr; double[] finalMarkArr; { System.out.println ("MENU"); System.out.println ("========================================"); System.out.println (" [1]. Display the results of all students"); System.out.println (" [2]. Display the students who have failed"); System.out.println (" [3]. Add a new student"); System.out.println (" [4]. Update assignment mark of a student"); System.out.println (" [0]. Exit"); System.out.println ("Enter your option: _____ "); System.out.println ("========================================="); } } public static void displayStudentResults(String[] nameArr, double[] caMarkArr, double[] ctMarkArr, double[] asgMarkArr, double[] finalMarkArr) { int [] numArr = new int[50]; System.out.println("Student Name" + "CA" + "CT" + "ASG" + "FINAL" + "GRADE"); for (int i=0; i<numArr.length; i++) { System.out.println(nameArr[i] + caMarkArr[i] + ctMarkArr[i] + asgMarkArr[i] + finalMarkArr[i]); numArr[i]=i+1; } } //Calculate Final marks to compute whether the student has passed & to know the grades public static double calculateFinalMarks(int count, double[] caMark, double[] ctMark, double[] asgMark) { int a = count; finalMark = (0.4 * caMark[a]) + (0.3 * ctMark[a]) + (0.3 * asgMark[a]); System.out.print(finalMark); count++; return finalMark; } public static void displayFailedStudents (String[] name, double[] caMark, double[] ctMark, double[] asgMark, doubl[] finalMark) { System.out.println("No" + "Student Name" + "CA" + "CT" + "ASG" + "FINAL" + "GRADE"); for (int l=0; l<count; l++) { if (finalMark < 50) System.out.print(name[l], caMark[l], ctMark[l], asgMark[l], finalMark[l]); } } public static void addNewStudent(int count) { System.out.println("Option 3: Add New Student"); System.out.println("Enter Student Name: "); String name = input.next(); System.out.println("Enter CA Marks: "); double caMarks = input.nextDouble(); System.out.println("Enter CT Marks: "); double ctMarks = input.nextDouble(); System.out.println("Enter ASG Marks: "); double asgMarks = input.nextDouble(); System.out.println("One Student Added."); count++; } public static void updateMarks(int count, double asgMark) { int i = count; System.out.println("Option 4: Update Assignment Mark of a Student: "); System.out.println("Enter the serial number of the student to update : "); i = input.nextInt(); System.out.println("Enter new assignment mark : "); double asgMark = input.nextDouble(); System.out.println("The assignment mark is updated. "); asgMark[count-1] = asgMarks; } public static char gradeMark( double finalMark) { char gradeMark = 0; if (finalMark >=80) System.out.println("Grade A"); if ((finalMark >=70) && (finalMark < 80)) System.out.println("Grade B"); if ((finalMark >=60) && (finalMark < 70)) System.out.println("Grade C"); if ((finalMark >= 50) && (finalMark < 60)) System.out.println("Grade D"); if (finalMark < 50) System.out.println("Grade F"); return gradeMark; } }
Is it working now? If not you need to post the full text of any error messages.
Have you looked at how to write methods?
http://docs.oracle.com/javase/tutori...O/methods.html
If you don't understand my answer, don't ignore it, ask a question.
this is the edited one
/*================================================================================== * FSP 2012 Assignment * Student ID : S10122534C * Student Name : Leonard Laura Rachel M * Module Group : FI05 * * ==================================================================================*/ import java.util.Scanner; public class S10122534c_Assignment { public static void main(String[] args) { final int MAXSIZE = 50; // maximum number of students String[] name = new String[MAXSIZE]; // array to store the names of the students double[] caMark = new double[MAXSIZE]; // array to store the Continuous Assessment marks double[] ctMark = new double[MAXSIZE]; // array to store the Common Test marks double[] asgMark = new double[MAXSIZE]; // array to store the Assignment marks double[] finalMark = new double [MAXSIZE]; // array to store the Final marks int count = 0; Scanner input = new Scanner(System.in); // initialize the array with students count = initialization(name, caMark, ctMark, asgMark); int choice; finalMark = calculateFinalMark(count,caMark, ctMark, asgMark); do { choice = input.nextInt(); switch (choice) { case 1: displayStudentResults(name, caMark, ctMark, asgMark, finalMark, count);break; case 2: diplayFailedStudents(name, caMark, ctMark, asgMark, finalMark, count);break; case 3: addNewStudent(count);break; case 4: updateMarks(asgMark, count);break; case 5: exit();break; default:System.out.print("Thank you."); } }while (choice != 0); } // method to initialize the arrays with students public static int initialization(String[] name, double[] caMark, double[] ctMark, double[] asgMark, double[] finalMark) { name [0] = "Agnes Tan"; caMark [0] = 75; ctMark [0] = 68; asgMark [0] = 82; name [1] = "Benny Ong"; caMark [1] = 66; ctMark [1] = 30; asgMark [1] = 35; name [2] = "Denise Ng"; caMark[2] = 55; ctMark [2] = 42; asgMark [2] = 50; name [3] = "Jimmy Tay"; caMark [3] = 80; ctMark [3] = 76; asgMark[3] = 82; name [4] = "Evelyn Low"; caMark [4] = 70; ctMark [4] = 60; asgMark [4] = 65; return 5; } public static void displayMenue() { String[] nameArr; double[] caMarkArr; double[] ctMarkArr; double[] asgMarkArr; double[] finalMarkArr; { System.out.println ("MENU"); System.out.println ("========================================"); System.out.println (" [1]. Display the results of all students"); System.out.println (" [2]. Display the students who have failed"); System.out.println (" [3]. Add a new student"); System.out.println (" [4]. Update assignment mark of a student"); System.out.println (" [0]. Exit"); System.out.println ("Enter your option: _____ "); System.out.println ("========================================="); } } public static void displayStudentResults(String[] nameArr, double[] caMarkArr, double[] ctMarkArr, double[] asgMarkArr, double[] finalMarkArr) { int [] numArr = new int[50]; System.out.println("Student Name" + "CA" + "CT" + "ASG" + "FINAL" + "GRADE"); for (int i=0; i<numArr.length; i++) { System.out.println(nameArr[i] + caMarkArr[i] + ctMarkArr[i] + asgMarkArr[i] + finalMarkArr[i]); numArr[i]=i+1; } } //Calculate Final marks to compute whether the student has passed & to know the grades public static double calculateFinalMarks(int count, double[] caMark, double[] ctMark, double[] asgMark) { int a = count; finalMark = (0.4 * caMark[a]) + (0.3 * ctMark[a]) + (0.3 * asgMark[a]); System.out.print(finalMark); count++; return finalMark; } public static void displayFailedStudents ( name,caMark,ctMark,asgMark,finalMark) { System.out.println("No" + "Student Name" + "CA" + "CT" + "ASG" + "FINAL" + "GRADE"); for (int l=0; l<count; l++) { if (finalMark < 50) System.out.print(name[l], caMark[l], ctMark[l], asgMark[l], finalMark[l]); } } public static void addNewStudent(int count) { System.out.println("Option 3: Add New Student"); System.out.println("Enter Student Name: "); String name = input.next(); System.out.println("Enter CA Marks: "); double caMarks = input.nextDouble(); System.out.println("Enter CT Marks: "); double ctMarks = input.nextDouble(); System.out.println("Enter ASG Marks: "); double asgMarks = input.nextDouble(); System.out.println("One Student Added."); count++; } public static void updateMarks(int count, double asgMark) { int i = count; System.out.println("Option 4: Update Assignment Mark of a Student: "); System.out.println("Enter the serial number of the student to update : "); i = input.nextInt(); System.out.println("Enter new assignment mark : "); double asgMark = input.nextDouble(); System.out.println("The assignment mark is updated. "); asgMark[count-1] = asgMarks; } public static char gradeMark( double finalMark) { char gradeMark = 0; if (finalMark >=80) System.out.println("Grade A"); if ((finalMark >=70) && (finalMark < 80)) System.out.println("Grade B"); if ((finalMark >=60) && (finalMark < 70)) System.out.println("Grade C"); if ((finalMark >= 50) && (finalMark < 60)) System.out.println("Grade D"); if (finalMark < 50) System.out.println("Grade F"); return gradeMark; } }
when you define your method, as you do on line#42, you DO include the variable types. ie String[], double[], double[] ...etc just before the variable name.
when you use the method, as you do on line#24, you DO NOT include the types. So your changes to line#42 have caused more errors.
finally on line#24, you still are sending one String array and three double arrays. The method expects to get one String array and FOUR double arrays, not just the three you are sending.
sorry tis the edited onee
/*================================================================================== * FSP 2012 Assignment * Student ID : S10122534C * Student Name : Leonard Laura Rachel M * Module Group : FI05 * * ==================================================================================*/ import java.util.Scanner; public class S10122534c_Assignment { public static void main(String[] args) { final int MAXSIZE = 50; // maximum number of students String[] name = new String[MAXSIZE]; // array to store the names of the students double[] caMark = new double[MAXSIZE]; // array to store the Continuous Assessment marks double[] ctMark = new double[MAXSIZE]; // array to store the Common Test marks double[] asgMark = new double[MAXSIZE]; // array to store the Assignment marks double[] finalMark = new double [MAXSIZE]; // array to store the Final marks int count = 0; Scanner input = new Scanner(System.in); // initialize the array with students count = initialization(name, caMark, ctMark, asgMark); int choice; finalMark = calculateFinalMark(count,caMark, ctMark, asgMark); do { choice = input.nextInt(); switch (choice) { case 1: displayStudentResults(name, caMark, ctMark, asgMark, finalMark, count);break; case 2: diplayFailedStudents(name, caMark, ctMark, asgMark, finalMark, count);break; case 3: addNewStudent(count);break; case 4: updateMarks(asgMark, count);break; case 5: exit();break; default:System.out.print("Thank you."); } }while (choice != 0); } // method to initialize the arrays with students public static int initialization(String[] name, double[] caMark, double[] ctMark, double[] asgMark, double[] finalMark) { name [0] = "Agnes Tan"; caMark [0] = 75; ctMark [0] = 68; asgMark [0] = 82; name [1] = "Benny Ong"; caMark [1] = 66; ctMark [1] = 30; asgMark [1] = 35; name [2] = "Denise Ng"; caMark[2] = 55; ctMark [2] = 42; asgMark [2] = 50; name [3] = "Jimmy Tay"; caMark [3] = 80; ctMark [3] = 76; asgMark[3] = 82; name [4] = "Evelyn Low"; caMark [4] = 70; ctMark [4] = 60; asgMark [4] = 65; return 5; } public static void displayMenue() { String[] nameArr; double[] caMarkArr; double[] ctMarkArr; double[] asgMarkArr; double[] finalMarkArr; { System.out.println ("MENU"); System.out.println ("========================================"); System.out.println (" [1]. Display the results of all students"); System.out.println (" [2]. Display the students who have failed"); System.out.println (" [3]. Add a new student"); System.out.println (" [4]. Update assignment mark of a student"); System.out.println (" [0]. Exit"); System.out.println ("Enter your option: _____ "); System.out.println ("========================================="); } } public static void displayStudentResults(String[] nameArr, double[] caMarkArr, double[] ctMarkArr, double[] asgMarkArr, double[] finalMarkArr) { int [] numArr = new int[50]; System.out.println("Student Name" + "CA" + "CT" + "ASG" + "FINAL" + "GRADE"); for (int i=0; i<numArr.length; i++) { System.out.println(nameArr[i] + caMarkArr[i] + ctMarkArr[i] + asgMarkArr[i] + finalMarkArr[i]); numArr[i]=i+1; } } //Calculate Final marks to compute whether the student has passed & to know the grades public static double calculateFinalMarks(int count, double[] caMark, double[] ctMark, double[] asgMark) { int a = count; finalMark = (0.4 * caMark[a]) + (0.3 * ctMark[a]) + (0.3 * asgMark[a]); System.out.print(finalMark); count++; return finalMark; } public static void displayFailedStudents ( name,caMark,ctMark,asgMark,finalMark) { System.out.println("No" + "Student Name" + "CA" + "CT" + "ASG" + "FINAL" + "GRADE"); for (int l=0; l<count; l++) { if (finalMark < 50) System.out.print(name[l], caMark[l], ctMark[l], asgMark[l], finalMark[l]); } } public static void addNewStudent(int count) { System.out.println("Option 3: Add New Student"); System.out.println("Enter Student Name: "); String name = input.next(); System.out.println("Enter CA Marks: "); double caMarks = input.nextDouble(); System.out.println("Enter CT Marks: "); double ctMarks = input.nextDouble(); System.out.println("Enter ASG Marks: "); double asgMarks = input.nextDouble(); System.out.println("One Student Added."); count++; } public static void updateMarks(int count, double asgMark) { int i = count; System.out.println("Option 4: Update Assignment Mark of a Student: "); System.out.println("Enter the serial number of the student to update : "); i = input.nextInt(); System.out.println("Enter new assignment mark : "); double asgMark = input.nextDouble(); System.out.println("The assignment mark is updated. "); asgMark[count-1] = asgMarks; } public static char gradeMark( double finalMark) { char gradeMark = 0; if (finalMark >=80) System.out.println("Grade A"); if ((finalMark >=70) && (finalMark < 80)) System.out.println("Grade B"); if ((finalMark >=60) && (finalMark < 70)) System.out.println("Grade C"); if ((finalMark >= 50) && (finalMark < 60)) System.out.println("Grade D"); if (finalMark < 50) System.out.println("Grade F"); return gradeMark; } }
Does it work now? If not post full text of error messages.
If you don't understand my answer, don't ignore it, ask a question.
So far so good.
Line#24 still has the error:
The method initialization(String[], double[], double[], double[], double[]) in the type S10122534c_Assignment is not applicable for the arguments (String[], double[], double[], double[])
Do you see line#42 your method signature says that method requires String[], double[], double[], double[], double[] and on line#24 when you try to use that method, you are not sending String[], double[], double[], double[], double[] ... you are sending String[], double[], double[], double[] ..... There is one double[] missing from line#24. According to the variable names you used, it seems to be the finalMark variable left out.
Ok done
But im still getting error in line 26 where they say illegal start of expression
/*================================================================================== * FSP 2012 Assignment * Student ID : S10122534C * Student Name : Leonard Laura Rachel M * Module Group : FI05 * * ==================================================================================*/ import java.util.Scanner; public class S10122534c_Assignment { public static void main(String[] args) { final int MAXSIZE = 50; // maximum number of students String[] name = new String[MAXSIZE]; // array to store the names of the students double[] caMark = new double[MAXSIZE]; // array to store the Continuous Assessment marks double[] ctMark = new double[MAXSIZE]; // array to store the Common Test marks double[] asgMark = new double[MAXSIZE]; // array to store the Assignment marks double[] finalMark = new double [MAXSIZE]; // array to store the Final marks int count = 0; Scanner input = new Scanner(System.in); // initialize the array with students count = initialization(name, caMark, ctMark, asgMark,finalMark); int choice; finalMark = calculatefinalMark(count,caMark, ctMark, asgMark, ); do { choice = input.nextInt(); switch (choice) { case 1: displayStudentResults(name, caMark, ctMark, asgMark, finalMark, count);break; case 2: diplayFailedStudents(name, caMark, ctMark, asgMark, finalMark, count);break; case 3: addNewStudent(count);break; case 4: updateMarks(asgMark, count);break; case 5: exit();break; default:System.out.print("Thank you."); } }while (choice != 0); } // method to initialize the arrays with students public static int initialization(String[] name, double[] caMark, double[] ctMark, double[] asgMark, double[] finalMark) { name [0] = "Agnes Tan"; caMark [0] = 75; ctMark [0] = 68; asgMark [0] = 82; name [1] = "Benny Ong"; caMark [1] = 66; ctMark [1] = 30; asgMark [1] = 35; name [2] = "Denise Ng"; caMark[2] = 55; ctMark [2] = 42; asgMark [2] = 50; name [3] = "Jimmy Tay"; caMark [3] = 80; ctMark [3] = 76; asgMark[3] = 82; name [4] = "Evelyn Low"; caMark [4] = 70; ctMark [4] = 60; asgMark [4] = 65; return 5; } public static void displayMenue() { String[] nameArr; double[] caMarkArr; double[] ctMarkArr; double[] asgMarkArr; double[] finalMarkArr; { System.out.println ("MENU"); System.out.println ("========================================"); System.out.println (" [1]. Display the results of all students"); System.out.println (" [2]. Display the students who have failed"); System.out.println (" [3]. Add a new student"); System.out.println (" [4]. Update assignment mark of a student"); System.out.println (" [0]. Exit"); System.out.println ("Enter your option: _____ "); System.out.println ("========================================="); } } public static void displayStudentResults(String[] nameArr, double[] caMarkArr, double[] ctMarkArr, double[] asgMarkArr, double[] finalMarkArr) { int [] numArr = new int[50]; System.out.println("Student Name" + "CA" + "CT" + "ASG" + "FINAL" + "GRADE"); for (int i=0; i<numArr.length; i++) { System.out.println(nameArr[i] + caMarkArr[i] + ctMarkArr[i] + asgMarkArr[i] + finalMarkArr[i]); numArr[i]=i+1; } } //Calculate Final marks to compute whether the student has passed & to know the grades public static double calculateFinalMarks(int count, double[] caMark, double[] ctMark, double[] asgMark) { int a = count; finalMark = (0.4 * caMark[a]) + (0.3 * ctMark[a]) + (0.3 * asgMark[a]); System.out.print(finalMark); count++; return finalMark; } public static void displayFailedStudents (String[] name, double[] caMark, double[] ctMark, double[] asgMark, double[] finalMark) { System.out.println("No" + "Student Name" + "CA" + "CT" + "ASG" + "FINAL" + "GRADE"); for (int l=0; l<count; l++) { if (finalMark < 50) System.out.print(name[l], caMark[l], ctMark[l], asgMark[l], finalMark[l]); } } public static void addNewStudent(int count) { System.out.println("Option 3: Add New Student"); System.out.println("Enter Student Name: "); String name = input.next(); System.out.println("Enter CA Marks: "); double caMarks = input.nextDouble(); System.out.println("Enter CT Marks: "); double ctMarks = input.nextDouble(); System.out.println("Enter ASG Marks: "); double asgMarks = input.nextDouble(); System.out.println("One Student Added."); count++; } public static void updateMarks(int count, double asgMark) { int i = count; System.out.println("Option 4: Update Assignment Mark of a Student: "); System.out.println("Enter the serial number of the student to update : "); i = input.nextInt(); System.out.println("Enter new assignment mark : "); double asgMark = input.nextDouble(); System.out.println("The assignment mark is updated. "); asgMark[count-1] = asgMarks; } public static char gradeMark( double finalMark) { char gradeMark = 0; if (finalMark >=80) System.out.println("Grade A"); if ((finalMark >=70) && (finalMark < 80)) System.out.println("Grade B"); if ((finalMark >=60) && (finalMark < 70)) System.out.println("Grade C"); if ((finalMark >= 50) && (finalMark < 60)) System.out.println("Grade D"); if (finalMark < 50) System.out.println("Grade F"); return gradeMark; } }
Which line is line 26?
If you don't understand my answer, don't ignore it, ask a question.
----jGRASP exec: javac -g S10122534c_Assignment.java
S10122534c_Assignment.java:26: cannot find symbol
symbol : method calculatefinalMark(int,double[],double[],double[])
location: class S10122534c_Assignment
finalMark = calculatefinalMark(count,caMark, ctMark, asgMark );
^
S10122534c_Assignment.java:31: displayStudentResults(java.lang.String[],double[],double[],double[],double[]) in S10122534c_Assignment cannot be applied to (java.lang.String[],double[],double[],double[],double[],int)
{ case 1: displayStudentResults(name, caMark, ctMark, asgMark, finalMark, count);break;
^
S10122534c_Assignment.java:32: cannot find symbol
symbol : method diplayFailedStudents(java.lang.String[],double[],double[],double[],double[],int)
location: class S10122534c_Assignment
case 2: diplayFailedStudents(name, caMark, ctMark, asgMark, finalMark, count);break;
^
S10122534c_Assignment.java:34: updateMarks(int,double) in S10122534c_Assignment cannot be applied to (double[],int)
case 4: updateMarks(asgMark, count);break;
^
S10122534c_Assignment.java:35: cannot find symbol
symbol : method exit()
location: class S10122534c_Assignment
case 5: exit();break;
^
S10122534c_Assignment.java:98: cannot find symbol
symbol : variable finalMark
location: class S10122534c_Assignment
finalMark = (0.4 * caMark[a]) + (0.3 * ctMark[a]) + (0.3 * asgMark[a]);
^
S10122534c_Assignment.java:99: cannot find symbol
symbol : variable finalMark
location: class S10122534c_Assignment
System.out.print(finalMark);
^
S10122534c_Assignment.java:101: cannot find symbol
symbol : variable finalMark
location: class S10122534c_Assignment
return finalMark;
^
S10122534c_Assignment.java:106: cannot find symbol
symbol : variable count
location: class S10122534c_Assignment
for (int l=0; l<count; l++)
^
S10122534c_Assignment.java:108: operator < cannot be applied to double[],int
if (finalMark < 50)
^
S10122534c_Assignment.java:109: cannot find symbol
symbol : method print(java.lang.String,double,double,double,double )
location: class java.io.PrintStream
System.out.print(name[l], caMark[l], ctMark[l], asgMark[l], finalMark[l]);
^
S10122534c_Assignment.java:116: cannot find symbol
symbol : variable input
location: class S10122534c_Assignment
String name = input.next();
^
S10122534c_Assignment.java:118: cannot find symbol
symbol : variable input
location: class S10122534c_Assignment
double caMarks = input.nextDouble();
^
S10122534c_Assignment.java:120: cannot find symbol
symbol : variable input
location: class S10122534c_Assignment
double ctMarks = input.nextDouble();
^
S10122534c_Assignment.java:122: cannot find symbol
symbol : variable input
location: class S10122534c_Assignment
double asgMarks = input.nextDouble();
^
S10122534c_Assignment.java:130: cannot find symbol
symbol : variable input
location: class S10122534c_Assignment
i = input.nextInt();
^
S10122534c_Assignment.java:132: asgMark is already defined in updateMarks(int,double)
double asgMark = input.nextDouble();
^
S10122534c_Assignment.java:132: cannot find symbol
symbol : variable input
location: class S10122534c_Assignment
double asgMark = input.nextDouble();
^
S10122534c_Assignment.java:134: array required, but double found
asgMark[count-1] = asgMarks;
^
S10122534c_Assignment.java:134: cannot find symbol
symbol : variable asgMarks
location: class S10122534c_Assignment
asgMark[count-1] = asgMarks;
^
20 errors
line 26 = finalMark = calculatefinalMark(count,caMark, ctMark, asgMark );
Here is your line#26:Do you see anything wrong with this line? Your method signature says the method expects (int, double[], double[], double[])finalMark = calculatefinalMark(count,caMark, ctMark, asgMark, );
You are sending (int, double[], double[], double[], ) ...Note the extra comma at the end before your closing ) ... The error is telling you it expected another variable after the comma and before the )
In short the comma just needs deleted. If you were to add another variable you would be sending too many variables to match the method signature.
Great, you got it, now compare line#26 to line#96. Specifically look at the method names.
ok done but im still getting errors
[case=java]
S10122534c_Assignment.java:26: '.class' expected
finalMark = calculatefinalMark(int count,double[] caMark,double[] ctMark,double[] asgMark );
^
S10122534c_Assignment.java:26: ';' expected
finalMark = calculatefinalMark(int count,double[] caMark,double[] ctMark,double[] asgMark );
^
S10122534c_Assignment.java:26: <identifier> expected
finalMark = calculatefinalMark(int count,double[] caMark,double[] ctMark,double[] asgMark );
^
S10122534c_Assignment.java:26: <identifier> expected
finalMark = calculatefinalMark(int count,double[] caMark,double[] ctMark,double[] asgMark );
^
S10122534c_Assignment.java:26: ';' expected
finalMark = calculatefinalMark(int count,double[] caMark,double[] ctMark,double[] asgMark );
^
S10122534c_Assignment.java:31: '.class' expected
{ case 1: displayStudentResults(String[] name, double[] caMark, double[] ctMark,double[] asgMark,double[] finalMark,int count);break;
^
S10122534c_Assignment.java:31: ';' expected
{ case 1: displayStudentResults(String[] name, double[] caMark, double[] ctMark,double[] asgMark,double[] finalMark,int count);break;
^
S10122534c_Assignment.java:31: <identifier> expected
{ case 1: displayStudentResults(String[] name, double[] caMark, double[] ctMark,double[] asgMark,double[] finalMark,int count);break;
^
S10122534c_Assignment.java:31: <identifier> expected
{ case 1: displayStudentResults(String[] name, double[] caMark, double[] ctMark,double[] asgMark,double[] finalMark,int count);break;
^
S10122534c_Assignment.java:31: <identifier> expected
{ case 1: displayStudentResults(String[] name, double[] caMark, double[] ctMark,double[] asgMark,double[] finalMark,int count);break;
^
S10122534c_Assignment.java:31: <identifier> expected
{ case 1: displayStudentResults(String[] name, double[] caMark, double[] ctMark,double[] asgMark,double[] finalMark,int count);break;
^
S10122534c_Assignment.java:31: ';' expected
{ case 1: displayStudentResults(String[] name, double[] caMark, double[] ctMark,double[] asgMark,double[] finalMark,int count);break;
^
S10122534c_Assignment.java:32: '.class' expected
case 2: diplayFailedStudents(String[] name, double[] caMark, double[] ctMark,double[] asgMark,double[] finalMark,int count);break;
^
S10122534c_Assignment.java:32: ';' expected
case 2: diplayFailedStudents(String[] name, double[] caMark, double[] ctMark,double[] asgMark,double[] finalMark,int count);break;
^
S10122534c_Assignment.java:32: <identifier> expected
case 2: diplayFailedStudents(String[] name, double[] caMark, double[] ctMark,double[] asgMark,double[] finalMark,int count);break;
^
S10122534c_Assignment.java:32: <identifier> expected
case 2: diplayFailedStudents(String[] name, double[] caMark, double[] ctMark,double[] asgMark,double[] finalMark,int count);break;
^
S10122534c_Assignment.java:32: <identifier> expected
case 2: diplayFailedStudents(String[] name, double[] caMark, double[] ctMark,double[] asgMark,double[] finalMark,int count);break;
^
S10122534c_Assignment.java:32: <identifier> expected
case 2: diplayFailedStudents(String[] name, double[] caMark, double[] ctMark,double[] asgMark,double[] finalMark,int count);break;
^
S10122534c_Assignment.java:32: ';' expected
case 2: diplayFailedStudents(String[] name, double[] caMark, double[] ctMark,double[] asgMark,double[] finalMark,int count);break;
^
S10122534c_Assignment.java:34: '.class' expected
case 4: updateMarks(double asgMark,int count);break;
^
S10122534c_Assignment.java:34: ';' expected
case 4: updateMarks(double asgMark,int count);break;
^
S10122534c_Assignment.java:34: ';' expected
case 4: updateMarks(double asgMark,int count);break;
^
S10122534c_Assignment.java:35: not a statement
case 5: exit[];break;
^
23 errors
[/case]
repost your code and lets have a fresh look from the same perspective