would like for you to create a class to register and assign grades to a student. You will need a constructor class to create a student. You will need a mutator class to set a grade (like in the Die class) You will need a getter class to return the grade for a student. Then you will need to write a main method to create two students, assign them grades, and then print the students names and grades to the screen.
Expert Answer
I have developed the above program using java. If any how you are expecting some other programming language please do let me know i can do it in very mean time.
//Student.java
/**
* Student class with name and grades
*
*/
public class Student
{
private String name;
private char grade;
/*
* Constructor for creating Student with name
*/
public Student(String name)
{
this.name = name;
}
/**
* Mutators for setting the grade
*/
public void setGrade(char grade)
{
this.grade = grade;
}
/**
* Acessor for getting the grade
* @return
*/
public char getGrade()
{
return this.grade;
}
/**
* Accessor for student name
*/
public String getName()
{
return this.name;
}
/**
* Main function
*/
public static void main(String args[])
{
//created two student and assign them grades
//using grade mutator
Student s1 = new Student(“Smith”);
s1.setGrade(‘B’);
Student s2 = new Student(“Mike”);
s2.setGrade(‘A’);
//printing the student name and
//grade using accessor
System.out.println(“Student Name Student Graden”);
System.out.println(s1.getName()+”ttt”+ s1.getGrade());
System.out.println(s2.getName()+”ttt”+ s2.getGrade());
}
}
//OUTPUT: