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.

Page 4 of 5 FirstFirst ... 2345 LastLast
Results 76 to 100 of 110

Thread: Help me PLEASe! I need to submit by 8.30am tmr!

  1. #76
    Member
    Join Date
    Jul 2012
    Posts
    57
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Help me PLEASe! I need to submit by 8.30am tmr!

    i dont know whats the problem with this linee
     public static void displayfailedStudents (String[] name, double[] caMark, double[] ctMark, double[] asgMark, double[] finalMark)

  2. #77
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: Help me PLEASe! I need to submit by 8.30am tmr!

    Quote Originally Posted by shadz92 View Post
    i dont know whats the problem with this linee
     public static void displayfailedStudents (String[] name, double[] caMark, double[] ctMark, double[] asgMark, double[] finalMark)
    That line of code is fine as it is. Sometimes when the error is given to you, the line number may be off. In this case your problem is actually on the preceeding line. The compiler has found an extra closing curly brace '}'

  3. #78
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: Help me PLEASe! I need to submit by 8.30am tmr!

    ...The reason why the compiler is off on the line number is because the compiler ignores white spaces (except when counting line numbers!). So as the compiler moves along your code, it encounters that extra closing curly brace, moves to the next line, and BAM, now it is confused. Well it didn't realize confusion til it was on the next line where your next method name starts, so that is the line number it reports back to you where a problem was found. Well in this case (and quite frequently) the preceeding line could have been valid, depending on what the next line is.

  4. #79
    Member
    Join Date
    Jul 2012
    Posts
    57
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Help me PLEASe! I need to submit by 8.30am tmr!

    Nw i got 1 error in line 115
     
    /*==================================================================================
     * 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 displayMenu()
    	 {
    	  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 calculatefinalMark(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 caMark =  input.nextDouble();
    		  System.out.println("Enter CT Marks:   ");
    		  double ctMark = input.nextDouble();
    		  System.out.println("Enter ASG Marks:  ");
    		  double asgMark = 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] = asgMark;
    		}
          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;
    		 }
    }

  5. #80
    Member
    Join Date
    Jul 2012
    Posts
    57
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Help me PLEASe! I need to submit by 8.30am tmr!

    S10122534c_Assignment.java:115: illegal start of expression
    public static void addNewStudent(int count)
    ^
    1 error

  6. #81
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: Help me PLEASe! I need to submit by 8.30am tmr!

    What this error message is trying to tell you is:
    Before you finished the definition of your method named displayfailedStudents, you started an illegal expression. In this case you started to define another method. In short that extra curly brace you had earlier, actually belongs at this point! There is a curly brace missing that closes off the previous method block. Another example of how the compiler is not real sure which line is in error. You can just count the given line number as a pointer to where the compiler was working when the compiler realized things are not in place, and not an indication of the exact location of the problem.

  7. #82
    Member
    Join Date
    Jul 2012
    Posts
    57
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Help me PLEASe! I need to submit by 8.30am tmr!

     
    /*==================================================================================
     * 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 displayMenu()
    	 {
    	  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 calculatefinalMark(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 caMark =  input.nextDouble();
    		  System.out.println("Enter CT Marks:   ");
    		  double ctMark = input.nextDouble();
    		  System.out.println("Enter ASG Marks:  ");
    		  double asgMark = 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] = asgMark;
    		}
          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;
    		 }
    }

  8. #83
    Member
    Join Date
    Jul 2012
    Posts
    57
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Help me PLEASe! I need to submit by 8.30am tmr!

    back to line 26 wit te error dude?
    I dunno whats happening???

  9. #84
    Member
    Join Date
    Jul 2012
    Posts
    57
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Help me PLEASe! I need to submit by 8.30am tmr!

    S10122534c_Assignment.java:26: cannot find symbol
    symbol : variable calculatefinalMark
    location: class S10122534c_Assignment
    calculatefinalMark = 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:99: 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:100: cannot find symbol
    symbol : variable finalMark
    location: class S10122534c_Assignment
    System.out.print(finalMark);
    ^
    S10122534c_Assignment.java:102: cannot find symbol
    symbol : variable finalMark
    location: class S10122534c_Assignment
    return finalMark;
    ^
    S10122534c_Assignment.java:108: cannot find symbol
    symbol : variable count
    location: class S10122534c_Assignment
    for (int l=0; l<count; l++)
    ^
    S10122534c_Assignment.java:112: operator < cannot be applied to double[],int
    if (finalMark < 50)
    ^
    S10122534c_Assignment.java:113: 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:121: cannot find symbol
    symbol : variable input
    location: class S10122534c_Assignment
    String name = input.next();
    ^
    S10122534c_Assignment.java:123: cannot find symbol
    symbol : variable input
    location: class S10122534c_Assignment
    double caMark = input.nextDouble();
    ^
    S10122534c_Assignment.java:125: cannot find symbol
    symbol : variable input
    location: class S10122534c_Assignment
    double ctMark = input.nextDouble();
    ^
    S10122534c_Assignment.java:127: cannot find symbol
    symbol : variable input
    location: class S10122534c_Assignment
    double asgMark = input.nextDouble();
    ^
    S10122534c_Assignment.java:135: cannot find symbol
    symbol : variable input
    location: class S10122534c_Assignment
    i = input.nextInt();
    ^
    S10122534c_Assignment.java:137: asgMark is already defined in updateMarks(int,double)
    double asgMark = input.nextDouble();
    ^
    S10122534c_Assignment.java:137: cannot find symbol
    symbol : variable input
    location: class S10122534c_Assignment
    double asgMark = input.nextDouble();
    ^
    S10122534c_Assignment.java:139: array required, but double found
    asgMark[count-1] = asgMark;
    ^
    19 errors

    ----jGRASP wedge2: exit code for process is 1.
    ----jGRASP: operation comple

  10. #85
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: Help me PLEASe! I need to submit by 8.30am tmr!

    Quote Originally Posted by shadz92 View Post
    back to line 26 wit te error dude?
    I dunno whats happening???
    You are making progress... You have already corrected a list of errors. There are many more still. However still, treat them one at a time for the reasons stated in my post#53.
    Sometimes the compiler gets confused and decides to quit before listing all of the errors. Sometimes the compiler THINKS there are multiple errors because of just one error. Do not get discouraged because the number of errors go up or down when you make changes. Every change you make causes the compiler to look at your new code from a new perspective. Take the first error, and fix it. Do not let those silly numbers or your deadline discourage you.
    Now I'll have a look at your code and post again....

  11. #86
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: Help me PLEASe! I need to submit by 8.30am tmr!

    as of your code posted in post#82:

    Line#26:
    finalMark = calculatefinalMark( count, caMark, ctMark, asgMark );
    your variable finalMark was declared as type double[] on line#20.
    you are assigning the return value of the method calculatefinalMark to the varaible finalMark.
    The return value of this method is double, not double[]. The compiler does not know what you meant to do. Did you mean to store a double in one index of your array finalMark? Did you mean to return an array of doubles from the method?

  12. #87
    Member
    Join Date
    Jul 2012
    Posts
    57
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Help me PLEASe! I need to submit by 8.30am tmr!

    so what should it be instead?

  13. #88
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: Help me PLEASe! I need to submit by 8.30am tmr!

    That is a question for the author of the code I'm afraid. What is the method supposed to do?

  14. #89
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: Help me PLEASe! I need to submit by 8.30am tmr!

    Looking at your code I would say you had intended to store the return value into one index of the array. It looks like your method calculates the value of the final mark for one student. I would say you should determine which student you are working with, one at a time, and get their final mark from your method, and save it in your finalMark array in the corresponding studend's index. But you wrote the program, you would know best what you meant to do.

  15. #90
    Member
    Join Date
    Jul 2012
    Posts
    57
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Help me PLEASe! I need to submit by 8.30am tmr!

    I really dont know mann!

  16. #91
    Member
    Join Date
    Jul 2012
    Posts
    57
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Help me PLEASe! I need to submit by 8.30am tmr!

    yes..i intend to get their final mark from method and save it finalMark..
    But i dont know how to do it?

  17. #92
    Member
    Join Date
    Jul 2012
    Posts
    57
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Help me PLEASe! I need to submit by 8.30am tmr!

    I really appreciate your helpp.
    But i really need to get my program to work
    Could you like get to the point?
    Im sorry mann
    Im rushing for time now

  18. #93
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: Help me PLEASe! I need to submit by 8.30am tmr!

    There are multiple ways to solve this...

    One way would be to loop through one at a time passing the necessary data to your calculatefinalMark method, getting the return value and storing it in your finalMark array.

    That is probably the way I would go. That seems to be the way you intended for it to work. Judging by the method...

    Now you have to think more about the problem at hand, and less about the error.

    If you want to calculate the final mark for one student, what is required?
    Well you would need to know which student and all of the marks needed to calculate his/her final mark. In your current method you pass in a reference to the array with all of the students' marks. This is a bit more overhead than you need for a method to do some math. You would only need to pass in the marks for the student in question at that time. So my suggestion would be to loop through your students name array, and for each student, use the index value of your loop to get the student's marks from each of the arrays, send them off to calculatefinalMark, and use the same index number to store the return in your finalMark array. This way student name[0] will correspond to finalMark[0].

  19. #94
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: Help me PLEASe! I need to submit by 8.30am tmr!

    Quote Originally Posted by shadz92 View Post
    I really appreciate your helpp.
    But i really need to get my program to work
    Could you like get to the point?
    Im sorry mann
    Im rushing for time now
    so far you have corrected many errors, but many more exist. Its too bad you put this off for so long and are now almost out of time. The best advice I have for you is to keep making the progress you have since your first post. Take one error at a time, and fix it. That is the process we all have to go through. I will be here for a while to keep offering help. Give that method a few thoughts and see what you come up with.

  20. #95
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: Help me PLEASe! I need to submit by 8.30am tmr!

    Quote Originally Posted by shadz92 View Post
    But i really need to get my program to work
    Could you like get to the point?
    There really is no "point" to get to. Of all the errors you have so far fixed, I got to the point for each of them. I pointed out your code, quoted the related error messages, explained what the error messages meant, and pointed you in the right direction for fixing the errors. Short of rewinding time for you there is not much more I can do to help you.

  21. #96
    Member
    Join Date
    Jul 2012
    Posts
    57
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Help me PLEASe! I need to submit by 8.30am tmr!

    can you giv me one example dude with agnes tan nam[0] and finalMark[0]

  22. #97
    Member
    Join Date
    Jul 2012
    Posts
    57
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Help me PLEASe! I need to submit by 8.30am tmr!

    its similar to what i've done right..
    but i dont know how to store it in the array

  23. #98
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,094
    Thanks
    48
    Thanked 2,152 Times in 2,125 Posts

    Default Re: Help me PLEASe! I need to submit by 8.30am tmr!

    theArray[theIndex] = aMethod(<the method's args here>);  //  store what method returns in an array
    If you don't understand my answer, don't ignore it, ask a question.

  24. #99
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: Help me PLEASe! I need to submit by 8.30am tmr!

    well the problem is you are not currently accessing your array one element at a time. So far you have only used every array as an entire set, and never individually. You need to set up a loop to go through each element first. Then work on each element

  25. #100
    Member
    Join Date
    Jul 2012
    Posts
    57
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Help me PLEASe! I need to submit by 8.30am tmr!

    is it this way
    [case=java]

    /*================================================= =================================
    * 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;

    do
    {
    choice = input.nextInt();
    switch (choice)
    { case 1: displayStudentResults( name, caMark, ctMark, asgMark, finalMark[0],finalMark[1],finalMark[2],finalMark[3],finalMark[4], 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 displayMenu()
    {
    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 calculatefinalMark(int count, double[] caMark, double[] ctMark, double[] asgMark)
    {
    {
    int a = count;
    finalMark[0] = (0.4 * caMark[a]) + (0.3 * ctMark[a]) + (0.3 * asgMark[a]);
    System.out.print(finalMark);
    count++;
    return finalMark[0];

    }
    {
    int b=count;
    finalMark[1]= (0.4 * caMark[b]) + (0.3 * ctMark[b]) + (0.3 * asgMark[b]);
    System.out.print (finalMark);
    count++;
    return finalMark[1];
    }

    {
    int c =count;
    finalMark[2]= (0.4 * caMark[c]) + (0.3 * ctMark[c]) + (0.3 * asgMark[c]);
    System.out.print (finalMark);
    count++;
    return finalMark[2];
    }

    {
    intd=count;
    finalMark[3]= (0.4 * caMark[d]) + (0.3 * ctMark[d]) + (0.3 * asgMark[d]);
    System.out.print (finalMark);
    count++;
    return finalMark[3];
    }

    {
    inte=count;
    finalMark[4]= (0.4 * caMark[e]) + (0.3 * ctMark[e]) + (0.3 * asgMark[e]);
    System.out.print (finalMark);
    count++;
    return finalMark[4];
    }
    {
    name[0]= finalMark[0];
    name[1]= finalMark[1];
    name[2]= finalMark[2];
    name[3]= finalMark[3];
    name[4]= finalMark[4];

    }
    }










    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 caMark = input.nextDouble();
    System.out.println("Enter CT Marks: ");
    double ctMark = input.nextDouble();
    System.out.println("Enter ASG Marks: ");
    double asgMark = 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] = asgMark;
    }
    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;
    }
    }






    [/case]

Page 4 of 5 FirstFirst ... 2345 LastLast

Similar Threads

  1. Replies: 1
    Last Post: January 31st, 2013, 03:55 AM
  2. Replies: 6
    Last Post: December 6th, 2011, 07:46 AM
  3. Notepad is opening on click of submit instead navigating to other page
    By pb60705 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: November 10th, 2011, 06:23 AM
  4. unable to go to next page...while clicking submit button
    By javaking in forum JavaServer Pages: JSP & JSTL
    Replies: 0
    Last Post: April 29th, 2010, 02:55 AM
  5. vending machine submit button help
    By maybach230 in forum Java Applets
    Replies: 3
    Last Post: April 23rd, 2010, 10:16 AM