CSCI300L Sample Exam 1
CSCI300L Sample Exam 1
Part 1. (65 pts) Implement the class Student as presented in the following UML diagram:
Student
-name: String //could be formed of more than two words
-id: int
-gender: char
-gpa: double
+Student(n: String, i: int, g: char, gp: double) (10 pts)
+getFirstName(): String (10 pts) //returns the first word in name
+countWordsInName(): int (5 pts) //returns the number of words in name
+setGpa(gp: double): void (5 pts)
+setId(i: int): void (5 pts)
+isHonor(): boolean (5 pts)
+formatName(): void (10 pts) //capitalizes the first letter of every word in name
+getName(): String (5 pts) //returns the name after formatting it
+printDesrciption(): void (10 pts)
Mr. Karim Hassan Assaf, ID : 11232 is an Honor student with GPA 3.9
Note that the name is preceded by Mr. for male students and Ms. for females.
Part 2. (35 pts) Write a driver class to test the Student class as follows:
a. Create a student object using any data of your choice (Not from the user and different from the above
example) (5 pts)
b. Change its id with any other id. (5 pts)
c. Display the first name of the object (5 pts)
d. Display the number of words forming the object’s name (5 pts)
e. Format his/her name and then display it (5 pts)
f. Display whether the student is an Honor student or not (5 pts)
g. Print the description of the object(5 pts)