COS1512 Assignment
3 (COMPLETE
ANSWERS) 2024
(160814) - DUE 23
August 2024
,COS1512 Assignment 3 (COMPLETE ANSWERS) 2024 (160814) - DUE 23
August 2024
Question 1 Consider the following structure used to keep record of a student’s
scores: struct Student { string name; int quiz1; int quiz2; int midtermExam; int
finalExam; } A student is assessed according to the following policies: 1. The
two quizzes are each marked out of 10. 2. The midterm exam and the final
exam are each marked out of 100 marks. 3. The final exam counts for 50% of
the grade, the midterm counts for 25%, and the two quizzes together count for
a total of 25%. (Do not forget to normalize the quiz scores. They should be
converted to a percentage before they are averaged in.) Turn the student
record into a class type rather than a structure type. The student record class
should have member variables for all the input data. Make all member
variables private. Include public member functions for each of the following: •
a default constructor that sets the student ‘s name to a blank string, and all the
scores to 0; • member functions to set each of the member variables to a
value given as an argument to the function (i.e. mutators); • member functions
to retrieve the data from each of the member variables (i.e. accessors); • and
a function that calculates and returns the student’s weighted average numeric
score for the entire course. Use this class in program which grades a student.
The program should read in the student’s name and scores and output the
student’s record as well as the student’s average numeric score for the entire
For assistance whatsapp +254702715801
, course. Use the keyboard to supply input and display the output on the
screen. Test your program with the following input: Student name: Johnny
Applemac Quiz 1: 7 Quiz 2: 5 Midterm exam: 65 Final exam: 73 Downloaded
by Corona Virus () lOMoARcPSD| COS1512/103/2024 3 Question 2 – a bit of
theory and terminology (a) What is the purpose of the keywords public and
private in the class declaration? (b) What is the difference between a class
and an object? (c) What does it mean to “instantiate” an object? (d) What is
the purpose of a constructor? (e) What is the difference between the default
constructor and the overloaded constructor? (f) What is the purpose of a
destructor? (g) What is the purpose of an accessor? (h) What is the purpose
of a mutator? (i) What is the purpose of the scope resolution operator? (j)
What is the difference between the scope resolution operator and the dot
operator? (k) What is the difference between a member function and an
ordinary function? (l) What is an abstract data type (ADT)? (m) How do we
create an ADT? (n) What are the advantages of using ADTs? (o) What is
separate compilation? (p) What are the advantages of separate compilation?
(q) What is a derived class? (r) What is the purpose of inheritance?
Downloaded by Corona Virus () lOMoARcPSD| COS1512/103/2024 4
Question 3 Consider the following class declaration: class PersonType {
public: PersonType(); PersonType(string n, int id, string bd); private: string
name; int ID; string birthday; }; Explain what is wrong with the following code
For assistance whatsapp +254702715801
3 (COMPLETE
ANSWERS) 2024
(160814) - DUE 23
August 2024
,COS1512 Assignment 3 (COMPLETE ANSWERS) 2024 (160814) - DUE 23
August 2024
Question 1 Consider the following structure used to keep record of a student’s
scores: struct Student { string name; int quiz1; int quiz2; int midtermExam; int
finalExam; } A student is assessed according to the following policies: 1. The
two quizzes are each marked out of 10. 2. The midterm exam and the final
exam are each marked out of 100 marks. 3. The final exam counts for 50% of
the grade, the midterm counts for 25%, and the two quizzes together count for
a total of 25%. (Do not forget to normalize the quiz scores. They should be
converted to a percentage before they are averaged in.) Turn the student
record into a class type rather than a structure type. The student record class
should have member variables for all the input data. Make all member
variables private. Include public member functions for each of the following: •
a default constructor that sets the student ‘s name to a blank string, and all the
scores to 0; • member functions to set each of the member variables to a
value given as an argument to the function (i.e. mutators); • member functions
to retrieve the data from each of the member variables (i.e. accessors); • and
a function that calculates and returns the student’s weighted average numeric
score for the entire course. Use this class in program which grades a student.
The program should read in the student’s name and scores and output the
student’s record as well as the student’s average numeric score for the entire
For assistance whatsapp +254702715801
, course. Use the keyboard to supply input and display the output on the
screen. Test your program with the following input: Student name: Johnny
Applemac Quiz 1: 7 Quiz 2: 5 Midterm exam: 65 Final exam: 73 Downloaded
by Corona Virus () lOMoARcPSD| COS1512/103/2024 3 Question 2 – a bit of
theory and terminology (a) What is the purpose of the keywords public and
private in the class declaration? (b) What is the difference between a class
and an object? (c) What does it mean to “instantiate” an object? (d) What is
the purpose of a constructor? (e) What is the difference between the default
constructor and the overloaded constructor? (f) What is the purpose of a
destructor? (g) What is the purpose of an accessor? (h) What is the purpose
of a mutator? (i) What is the purpose of the scope resolution operator? (j)
What is the difference between the scope resolution operator and the dot
operator? (k) What is the difference between a member function and an
ordinary function? (l) What is an abstract data type (ADT)? (m) How do we
create an ADT? (n) What are the advantages of using ADTs? (o) What is
separate compilation? (p) What are the advantages of separate compilation?
(q) What is a derived class? (r) What is the purpose of inheritance?
Downloaded by Corona Virus () lOMoARcPSD| COS1512/103/2024 4
Question 3 Consider the following class declaration: class PersonType {
public: PersonType(); PersonType(string n, int id, string bd); private: string
name; int ID; string birthday; }; Explain what is wrong with the following code
For assistance whatsapp +254702715801