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.

Results 1 to 3 of 3

Thread: students marks coding

  1. #1
    Junior Member
    Join Date
    Mar 2013
    Location
    malaysia
    Posts
    5
    My Mood
    Confused
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation students marks coding

    i want to calculate 5 student marks given marks for test 1 & test 2. the weightage for test1 is 15% and test2 is 25%.
    the coding will display the following status :

    PHP Code:
    Total Marks    Status
    0  20     Cannot sit 
    final examination
    21  25    Must sit the 3rd test
    26  35    Allow to sit the 
    final examination
    36  40    Excluded from sitting the 
    final examination 

    the result of coding should :

    PHP Code:
        Display the student nametotal marks and status for each student in the function named void Display(). 
    and here is my code :

    import java.io.*;
     
    public class Assigment1
    {
    	public static void main(String[] args)
    	{
    		String studName[] = {"Amad bin Abu", "Dollah bin Daud", "Milah bin Malek","Sarah bin Shamsuddin","Idris bin Ibrahim"};
    		int test1[] = {9,73,76,85,70};
    		int test2[] = {9,64,79,87,72};
    		int totalMarks[] ={0,0,0,0,0};
    		String[] status = new String [5];
     
    		CalculateMarks(test1,test2,totalMarks);
    		DetermineStatus(totalMarks,status);
    		Display(studName,totalMarks,status);
    	}
     
     
    	public static void CalculateMarks(int t1[],int t2[],int tmark[])
    	{
    		for(int i=0;i<marks.length;i++)
    		{
    			int mark = 0,test1,test2;
    			test1 = (15*test1[i])/100;
    			test2 = (25*test2[i])/100;
    			totalMark = test1[i] + test2[i];
    		}
    	}
     
     
    	public static void DetermineStatus(int[] tmark,String status[])
    	{
    		int totalMarks = 0;
     
    		for(int i=0;i<marks.length;i++)
    		{
    			if(totalMarks[i] >=0 && totalMarks[i] <=20)
    			{
    				status[i]="Cannot sit final exam";
    			}
    			if(totalMarks[i] >=21 && totalMarks[i] <=25)
    			{
    				status[i]="Must sit the 3rd test";
    			}
    			if(totalMarks[i] >=26 && totalMarks[i] <=35)
    			{
    				status[i]="Allow to sit the final exam";
    			}
    			if(totalMarks[i] >=36 && totalMarks[i] <=40)
    			{
    				status[i]="Excluded from sitting the final exam";
    			}
    	}
     
     
    	public static void Display(String studName[],int[] tmark,String status[])
    	{
    		for(int i=0;i<marks.length;i++)
    		{
    			System.out.print("\n Student Name : "+studName[i]);
    			System.out.print("\n Total Mark : "+tmark[i]);
    			System.out.print("\n Status : "+status[i]);
    		}
    		return;
    	}
    }


    my problem is:
    -why I get
    PHP Code:
    illegal start of expression 
    in the line 56..?


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,172
    My Mood
    Hungover
    Thanks
    141
    Thanked 600 Times in 515 Posts

    Default Re: students marks coding

    What is on line 56?

    Make sure you check for missing semicolons, extra or missing brackets, etc.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Junior Member
    Join Date
    Mar 2013
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: students marks coding

    At a quick glance I see your trying to use var mark before you declare it here
    for(int i=0;i<marks.length;i++)
    		{
    			int mark = 0,test1,test2;
    			test1 = (15*test1[i])/100;
    			test2 = (25*test2[i])/100;
    			totalMark = test1[i] + test2[i];
    		}

Similar Threads

  1. Replies: 2
    Last Post: February 19th, 2012, 06:36 AM
  2. A program that counts the number of punctuation marks in a text file
    By Twoacross in forum What's Wrong With My Code?
    Replies: 1
    Last Post: October 21st, 2011, 04:03 PM
  3. Help! Image leaving marks
    By nivangerow in forum AWT / Java Swing
    Replies: 5
    Last Post: September 10th, 2011, 03:00 PM
  4. Replies: 5
    Last Post: August 28th, 2011, 04:48 PM
  5. Forum list improperly marks whats unread
    By Lord.Quackstar in forum The Cafe
    Replies: 14
    Last Post: June 18th, 2010, 01:14 AM

Tags for this Thread