1st class
public class Student {

private String name;
private double id, examMark, courseMark, totalMark,grade;
Student(String name,double id,double examMark,double courseMark){

    this.name=name;
    this.id=id;
    this.examMark=examMark;
    this.courseMark=courseMark;
    this.totalMark=getMark(getExammark(),getCoursemark());
    this.grade=grade;

}

public String getName()// to return name of student
{
return name;
}
public double getID()//to return id of the student
{
return id;
}
public double getExammark() // return exammark of the student
{
return examMark;
}
public double getCoursemark()// return coursemark of the mark
{
return courseMark;
}
public void print()
{
System.out.println("ID: " + id);
System.out.println("ExamMark: " + examMark);
System.out.println("CourseMark: " + courseMark);
System.out.println("Total Mark:"+ totalMark);
System.out.println("Grade:"+ grade);
}

// to return total mark of student
public double getMark(double courseMark, double examMark)
{
if(courseMark<50)
{

    if(examMark<courseMark)
    {
        return examMark;
    }
    else
    {
        return courseMark;
    }
}
else if(examMark<50)
{
    return examMark;
}
else
{
    return (courseMark+examMark)/2;
}

}
// to return student grade
public String getGrade()
{
if(totalMark>=0 && totalMark<50)
return "NN";
else if (totalMark>=50 && totalMark<60)
return "PA";
else if (totalMark>=60 && totalMark<70)
return "CR";
else if (totalMark>=70 && totalMark<80)
return "DI";
else if (totalMark>=80 && totalMark<100)
return "HD";
else return "OUT OF RANGE";

}
// to set student’s exam mark
public void setExamMark (double examMark) {
this.examMark=examMark;
this.totalMark=getMark(getExammark(),getCoursemark());
}
// to set student’s course mark
public void setCourseMark (double courseMark){
this.courseMark=courseMark;
this.totalMark=getMark(getExammark(),getCoursemark());

     }

}
2nd class
import java.util.*;
public class TestStudent{
public static void main(String[] args){
Scanner input=new Scanner(System.in);

    List<Student> studentsList = new ArrayList<Student>();

    int temp,option;
    double examMark=-1,courseMark=-1;
    System.out.println("Please enter number of student marks you would like to add");
    temp = input.nextInt();
    for (int i=0;i<temp;i++){
    System.out.println("Please enter student name:");
    String name=input.next();
    System.out.println("Please enter student id:");
    int id=input.nextInt();
    examMark=-1;
    courseMark=-1;
    while(examMark>100 || examMark<0){
    System.out.println("Please enter exam mark:");
    examMark=input.nextDouble();
    }
    while(courseMark>100 || courseMark<0){
    System.out.println("Please enter course mark:");
    courseMark=input.nextDouble();
     }
     studentsList.add( new Student(name,id,examMark,courseMark));

    }
do{

        System.out.println("Welcome to Grade Calculation System");
        System.out.println("----------------------------------------");
        System.out.println("");
        System.out.println("1. Display a Student Mark");
        System.out.println("2. Change Student Mark");
        System.out.println("3. Print out information for all students");
        System.out.println("4. Exit program");
        option=input.nextInt();

switch (option)
{

case 1:

System.out.println("1. Display a Student Mark");
System.out.println("Please enter name of student you would display mark for ");
String name = input.next();

for(Student s: list){
System.out.println("ID:"+s.getID()+"\t");
System.out.println("Exam Mark:"+s.getExammark());
System.out.println("Course Mark:"+s.getCoursemark());
System.out.println("Total Mark:"+s.getMark()+"%");
System.out.println("Grade:"+s.getGrade());
}
break;
case 2:

System.out.println("Please enter student name:");
name = input.next();
if (s.getName() == name)
{

                     System.out.println("Please enter exam mark: " + s.getName().ToString()+": ");

                     System.out.println("Please enter course mark: " + s.getName().ToString()+": ");

                      System.out.println("Marks Changed");
                                }
                                else{


                                System.out.println("Invalid Entry! Marks must be between 0 - 100!");
                                }
                                        break;


    case 3:
        for(Student s: list){
        System.out.println(s.getName()+"\t"+s.getID()+"\t"+s.getExammark()+"\t"+s.getCoursemark());

}
break;

                                    }

        if(option == 4) break;

}
while (true);

}
}

i think i got a lot of mistake in it but at least i try, so my question is how do i store it and called up them?

You know, a mixture of code in blue and background code confuses others. Please tab the background code.

I mean:-

code

code

code

can be corrected to

code 

code

code

owww sorry sorry, my bad. Anyway, back to the topic, i don't seem to get how the called up work.

It's okay. Anyways, what is the problem? A few tips:-
1. I suggest that if you are a beginner stay away from the foreach loop ( for(a : b) ) and use iteration. The iterator class:-
Iterator
2. Use input.nextLine() instead of input.next();.
But again, these two tips are my personal opinion. Just in case you are more experienced with the options against my recommendations, feel free to use your own. I do not know about the do...while() loop. So I am really, really, really sorry if I can't help with that.

Best of luck with your program from me.

how do i store it and called up them?

What is the "it" you are talking about? If its a variable, please give us the name of the variable.
What does "called up" mean?
Where in your code are you having the problem. Can you name the methods and classes where?

umm... ok so far i have redo it, and now my question is... how should i make it to store two student instead of one?
when i input one student info it always skip to the display section and after that it will repeat for another student.
so my problem actually is that i want the array to store number of students i intend to record marks.

and how do i compare for example.
Please enter student name: Sam
so it will display all the sam info

> [Link Anchor Text](import java.util.Scanner;**
> 
> class TestStudent
> {
>    public static void main(String args[])
>    {
>       Scanner input = new Scanner( System.in );
>       int temp,option;
>       String name,id;
>       double examMark=-1,courseMark=-1;
>       Student list[];
> 
>         System.out.println("Please enter number of student marks you would like to add");
>     temp = input.nextInt();
>     for (int i=0;i<temp;i++){
>       System.out.println("Please enter student name:");
>       name=input.next();
>       System.out.println("Please enter student id:");
>       id=input.next();
>       examMark=-1;
>       courseMark=-1;
>       while(examMark>100 || examMark<0){
>       System.out.println("Please enter exam mark:");
>       examMark=input.nextDouble();
>       }
>       while(courseMark>100 || courseMark<0){
>       System.out.println("Please enter course mark:");
>       courseMark=input.nextDouble();
> 
>        }
>        Student student = new Student(name,id,examMark,courseMark);
> 
>        System.out.println("Welcome to Grade Calculation System");
>        System.out.println("----------------------------------------");
>        System.out.println("");
>        System.out.println("1. Display a Student Mark");
>        System.out.println("2. Change Student Mark");
>        System.out.println("3. Print out information for all students");
>        System.out.println("4. Exit program");
>        option=input.nextInt();
>  switch (option)
>  {
>   case 1:
>        System.out.println("Display a student mark");
>          System.out.println("Please enter name of student you would display mark for  ");
>          name = input.next();
> 
>           if (name ==student.getName())   {
>         System.out.println("ID " + student.getID());
>         System.out.println("CourseaMark " + student.getCoursemark());
>         System.out.println("Exam Mark " + student.getExammark());
>                  }
>            else {
>         System.out.println("I am sorry. Student does not exist");
>                                     break;
>                 }
>     case 2:
>       System.out.println("Change Student Mark");
>         System.out.println("Please enter name of student you would like to change mark for:");
>         name = input.next();
>          if (name ==student.getName()){
>         System.out.println("Please enter exam mark: ");
> 
>         System.out.println("Please enter course mark: ");
> 
>         System.out.println("Marks Changed");
>          }
>    case 3:
>       student.print();
>          }
>     }
>     }
> })

**

oh and how come i get grade null. ><"

    public class Student {


    private String name, id, grade;
    private double examMark, courseMark, totalMark;
    Student(String name,String id,double examMark,double courseMark){

        this.name=name;
        this.id=id;
        this.examMark=examMark;
        this.courseMark=courseMark;
        this.totalMark=getMark(getExammark(),getCoursemark());
        this.grade=grade;

   }

   public String getName()// to return name of student
   {
    return name;
   }
   public String getID()//to return id of the student
   {
    return id;
   }
    public double getExammark() // return exammark of the student
   {
    return examMark;
   }
    public double getCoursemark()// return coursemark of the mark
   {
    return courseMark;
   }

   public void print()
   {
    System.out.println("Name: " + name);
    System.out.println("ID: " + id);
    System.out.println("ExamMark: " + examMark);
    System.out.println("CourseMark: " + courseMark);
    System.out.println("Total Mark:"+ totalMark);
    System.out.println("Grade:"+ grade);
   }

   // to return total mark of student
   public double getMark(double courseMark, double examMark)
   {
    if(courseMark<50)
    {

        if(examMark<courseMark)
        {
            return examMark;
        }
        else
        {
            return courseMark;
        }
    }
    else if(examMark<50)
    {
        return examMark;
    }
    else
    {
        return (courseMark+examMark)/2;
    }
   }
   // to return student grade
   public String getGrade()
   {
        if(totalMark>=0 && totalMark<50)
            return "NN";
        else if (totalMark>=50 && totalMark<60)
            return "PA";
        else if (totalMark>=60 && totalMark<70)
            return "CR";
        else if (totalMark>=70 && totalMark<80)
            return "DI";
        else if (totalMark>=80 && totalMark<100)
            return "HD";
        else return "OUT OF RANGE";

   }
   // to set student’s exam mark
   public void setExamMark (double examMark) {
   this.examMark=examMark;
   this.totalMark=getMark(getExammark(),getCoursemark());
   }
   // to set student’s course mark
   public void setCourseMark (double courseMark){
   this.courseMark=courseMark;
   this.totalMark=getMark(getExammark(),getCoursemark());

         }
   }

Do you get any warning when you compile the code?
When I compile with: javac.exe -Xlint
I get some important warnings that will effect how your code executes. Recompile with the -Xlint compiler option.

No i didn't get any warning.

oh and the input.nextLine skip one of the option?

One problem: Use the equals() method to compare Strings not the == operator.

No i didn't get any warning.

Did you use the -Xlint option?

so.. is it like this?

    if (this.name.equals(student.getName))

Does that compile?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.