This my main
import java.util.*;
public class StudentList2 {
public static void main(String[] args) {
// TODO Auto-generated method stub
ArrayList<StudentApp2> studentlist2 = new ArrayList<StudentApp2>();
StudentApp2 nextStudent;
String fname;
String sname;
int grade;
int num = 3;
Scanner kb = new Scanner(System.in);
/// Do
/// while
///public void enterStudents();{
for (int i=0; i < 3; i++){
System.out.println("Enter Firstname");
fname = kb.nextLine();
System.out.println("Enter Surname");
sname = kb.nextLine();
System.out.println("Enter Grade");
grade = kb.nextInt();
kb.nextLine();
nextStudent = new StudentApp2 (fname,sname,grade);
studentlist2.add(nextStudent);
}
}
//public void ListSTud()
{
// String mark = "";
for (int j = 0; j < 3; j++){
System.out.println(StudentList2.get(j).toString()) ;
}
}
}
This my class
import java.util.*;
public class StudentApp2 {
private String fname;
private String sname;
private int grade;
private String mark;
public StudentApp2 (String ipName, String ipsecondName, int ipgrade){
fname = ipName;
sname = ipsecondName;
grade = ipgrade;
getGrade();
}
public String toString (){
return("The name of this student is "+fname+" "+sname+" The grade is "+grade+" "
+ "The mark is "+mark+" " );
}
public String getFname() {
return fname;
}
public void setFname(String fname) {
this.fname = fname;
}
public String getSname() {
return sname;
}
public void setSname(String sname) {
this.sname = sname;
}
public void getGrade() {
if( grade >= 85 && grade <= 100 ){
mark = "Distinction";
}
else if( grade >= 65 && grade <= 84 ){
mark = "Merit";
}
else if( grade >= 40 && grade <= 64 ){
mark = "Pass";
}
else if( grade <= 39 ){
mark = "Fail";
}
}
public void setGrade(int grade) {
this.grade = grade;
}
}
--- Update ---
Sorry the is in the main at the end with my get from toString