Post date: Dec 08, 2015 5:43:46 PM
Exam Review
Ex 1:
Implement a Student class with the following fields, constructors and methods:
Fields:
private final int studentID
String name;
double totalScore;
int numberOfQuizzes;
Constructors:
public Student(int studentID, String name, double score)
public Student(int studentID, double score, String name)
public Student(int studentID, String name)
Methods:
public int getID()
public String getName()
public double getAverage( ) //this should return zero if no quiz has been taken.
public double getTotalScore( )
public void addQuiz(double score)
public void printStudent( ) //this should print the student’s ID, name and average score
public String toString( )
Write an application TestStudent that prompts for and reads a student name. It then creates a Student object. It then prompts for and reads the scores of the student in three quizzes and add each to the totalScore of the student using addQuiz() method. Finally, the application prints the student object using the printStudent() method.
Sample output:
Enter name of Student: Ahmad Omar
Enter grade of quiz#1 for Ahmad Omar: 20
Enter grade of quiz#2 for Ahmad Omar: 17
Enter grade of quiz#3 for Ahmad Omar: 19
ID: 33110123 Name: Ahmad Omar, Quiz Average: 18.67
Ex 2:
Implement the following class Circle