Assignment 2

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Assignment # 2

Due Date: After one week

Object Oriented Programming


using C++
Question No 1: Write a program which demonstrates all relational operators.
Question No 2: Concept of User defined function with passing argument, Write a program
which defined at least 3 different user defined function, you have to pass 7 different types of
argument as a local variable to these functions.
Question No 3: Define a class with at least 7 different data member (with to data type). Write
to function SetData () to assign values to data member and GetData () to return (display on
screen) the values of data members. Dont use constructor to initialize the data member. Dont
take values from the user in main function rather pass constant values as arguments? (Use
concept of passing values during compilation time).
Question No 4: Define a class with at least 7 different data member (with respect to data type).
Write to function SetData () to assign values to data member and GetData () to return (display on
screen) the values of data members. Dont use constructor to initialize the data member. Dont
pass constant as a function argument, rather take values from the user in client / main function
and pass variable as argument. (Use concept of taking values during run time from the user).
Question No 5: Re-Write question No 4 by this time input 6 subject marks from the user and
properly calculate percentage of the students by using the formula (Obtained marks * 100)/ Total
Marks, in main function.

Question No 6: Write a program having 7 data member all of different data types, use
constructor 2 constructor with 3 and 4 argument to initialize the data member.(initialize the data
member during object creation ) Provide values to constructor during compilation time.

Question No 7: Re-write the Question No 6, by this time provide values to the constructor
during run time, and i.e. pass variables instead of constant values. (Take value from user inside
the main function).

Question No8:
Create a class of student which stores characteristics of student like studentID, studentName,
studentDOB, studentGPA, StudentAddress of last 5 semesters and other related information of
the student.
a. How many object will be there in your class? It should be user dependent, means run time
will be decide that how many object will be there in your main client code.
b. Calculate the CGPA of each student using function calculateCGPA(). The function body
will contain complete method of CGPA calculation.
c. Student with highest CGPA will be considering CR of the class. There should be a function
which will compare the CGPA of students and will declare a student having greater CGPA
as CR.
d. ScholorshipAward() function will be there in your class, which will compare CGPA of all
the students and will award scholarship to only those students who have CGPA >=3.0.
e. Program should be able to take input of 5 students from user; definitely there will be a
function which will take input from the user.
f. You have to use the Setter for setting the values of the data members of the class and
Getter function for getting the values of the data members of the class.
g. Default value for each student GPA should be 3.0. (You have to use an array for storing
GPAs of last 5 semesters. You may simply initialize the array with 3.0 in constructor).
h. Assign one student record to another student using user defined copy constructor.
i. A special function NumberOfObject() will be there in your class which display total
number of declared object in main client, this function must be a static function.
j. All data members should be private.
k. Member functions can be public.
l. Setter factions should also be private.
m. Use separate Setter and Getter for data member of the class.
Note: THERE SHOULD BE 3 FILES; FIRST CONTAINING INTERFACE OF THE CLASS (STUDENT.H),
SECOND CONTAINING IMPLEMENTATION (STUDENT.CPP) AND THIRD CONTAINING THE CLIENT
(MAIN FUNCTION).
Question No10: (understanding of the question is part of assignment)
Being a University teacher I want to develop software which performs the grading task related to
Assignment, Quiz, Mid Term and final Term. I need your help, you are requested to design such

program, which takes information about a test, assignment or exam and save them in a data file. The
first portion of program should ask.

(a). Course Name,


(b) assignment/test/exam title such as Assignment I or Midterm Exam, Quiz No 1 or Final Term Exam
(c) Number of students in the class,
(d) Each student's name and score on the assignment/test/exam, and
(e) The file name for the data to be saved to.
The second portion of program takes exam data from a data file specified by the user and calculate the
class average for that particular test/exam/assignment. The output should be in the following format.
(NOTE: pay attention to the alignment)
Course Name: Introduction to object-Oriented Programming with C++
Grading Item: Assignment I
Number of Students: 5
Student Name
Student Score
Grade
------------------- -------------------- --------------------Amir Ikram
80.8
B+
Asad Khan
60.4
C
Zaroon Khattak
100.0
A++
Maria Khan
78.9
A
Tahir Abasi
100.0
A++
------------------- ------------------- -------------------Class Average:
84.02

Best of Luck

You might also like