Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
26 views

Lab 3

This document outlines a lab assignment for an object-oriented programming course. The assignment involves defining a C++ Student class to represent students with ID, name, and grades in 20 courses. It asks students to implement member variables, constructors, getter/setter methods, and methods to calculate GPA, number of grades above GPA, and number of grades below a given mark. The main function is to create Student objects, set their grades, call methods to compare their GPAs and number of high grades, and print results.

Uploaded by

waelabood51
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views

Lab 3

This document outlines a lab assignment for an object-oriented programming course. The assignment involves defining a C++ Student class to represent students with ID, name, and grades in 20 courses. It asks students to implement member variables, constructors, getter/setter methods, and methods to calculate GPA, number of grades above GPA, and number of grades below a given mark. The main function is to create Student objects, set their grades, call methods to compare their GPAs and number of high grades, and print results.

Uploaded by

waelabood51
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Princess Sumaya University for Technology

King Hussein School for Information Technology


Computer Science Department

CS11253 - Object Oriented Programming Lab


Spring 2024

Lab Assignment # 3

Name: ID: Section:

Lab Objectives:

 Learn how to define a simple class and implement its member functions.
 Learn how to use getters and setters
 Learn how to use a user-defined class in an application.

Max Mark Your mark

Q1 50
Q2 50
total 100
QUESTION 1: Assume that we want to track student’s information of a specific major.
Each student takes the same 20 mandatory courses during his/her study. Also, each
student has an ID and a name. Write a C++ Student class to represent a Student as the
following:

1. Define member variables to represent the id of type integer, name of type string, and
grades as an array of integers of size 20. (6 marks)
2. A default constructor that initializes the student id to 0, name to “”, and grades to 0.
(4 marks)
3. An initializer constructor that receives values for id and name, sets and grades to 0.
(4 marks)
4. Define a setter and getter for ID, and name. (12 marks)
5. Define a setter for grades which receives an array of integers that represent the
grades of courses for the students. Assume the size of the received array is 20. Note
that grades take value between 0 and 100. (7 marks)
6. float GetGPA() member function that returns the GPA of the student. This
represents the average of student’s grades. (5 marks)
7. int AboveGPA() member function that returns the number of grades that are higher
than the students GPA. (6 marks)
8. int LessThan(int mark) member function that returns the number of grades that are
less than the given mark parameter. (6 marks)
QUESTION 2: Write a main function that uses the Student class done in the previous
question. In the main function, do the following:

1. Define two Student objects s1 and s2 where s1 uses the default constructor and s2
uses the initializer constructor. Initialize s2 with user inputs for ID and name. (10
marks)
2. Define two arrays of integers of size 20, mark1, and mark2. Let the user fill them.
(10 marks)
3. Set mark1 as grades of student s1, and mark2 as grades for student s2. (6 marks)
4. Write a separate function called HigherGPA that receives two student objects and
return a Boolean value. The function should return true if the first student has higher
GPA, false otherwise. (6 marks)
5. Call the function HigherGPA using students s1, and s2. And print out “s1 has higher
GPA than s2” or “s2 has higher or equal GPA to s1”. (4 marks)
6. Write a separate function called MoreGrades that receives two student objects and
return a Boolean value. The function should return true if the first student has more
grades above his/her GPA than other student’s number of grades higher than his/her
GPA, false otherwise. (6 marks)
7. Call the function MoreGrades using students s1, and s2. And print out “s1 has more
number of grades higher than his/her GPA” or “s2 has more number of grades higher
than his/her GPA”. (4 marks)
8. In the main function print how many marks in object s1 less than 60. (4 marks).

GOOD LUCK

You might also like