0% found this document useful (0 votes)
83 views

Assignment 2: Question No 1 (20 Marks)

The document provides instructions for an assignment to create a Student class with data members for name, CGPA, degree, and a static variable to count students, and includes functions to set student data, display student data, and display the total student count. Students are to create Student objects, set their data using the set function, display the data using the display function, and output the total count at the end. They are asked to submit their coded solution along with screenshots and files.

Uploaded by

Malik Ravel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
83 views

Assignment 2: Question No 1 (20 Marks)

The document provides instructions for an assignment to create a Student class with data members for name, CGPA, degree, and a static variable to count students, and includes functions to set student data, display student data, and display the total student count. Students are to create Student objects, set their data using the set function, display the data using the display function, and output the total count at the end. They are asked to submit their coded solution along with screenshots and files.

Uploaded by

Malik Ravel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

OOP V2

ASSIGNMENT 2

QUESTION NO 1 ( 20 MARKS)

1. CREATE A CLASS
You are supposed to create a class Student
This class will hold (
string Student name,
double CGPA,
string degree,
static int count_total_no_of_student_enrolled,
and a constant variable holding university name=umt.
)

2. CREATE setstudent(string a,double b,string c) //Define this


function outside the class (Scope resolution operator)
 Set value to their specific data member
 Increase static variable by one using increment operator.

3. CREATE displaystudent() //Define this function outside the


class (Scope resolution operator)
 Display name,cgpa,degree,university of student here

4. CREATE display_total_no_of_student() //Define this function


outside the class (Scope resolution operator)
 Display total number of student here using static data member

5. MAIN
You have to create 3 objects.
Set their values using setstudent() function.
Display their values using displaystudent() function.
At the end, use display_total_no_of_student() function to check how many
students are created.

6. SUBMISSION FORMAT
You have to write code on paper and also on compiler
 Attach photo of paper in world document
 Also attach screenshot of output.
 Also attach .cpp file of your code
Compress file and submit it as one single file. (.rar)
#include<iostream>
#include<string>
using namespace std;
class Student
{
private:
string Student_name;
double CGPA;
string Degree;
const string x = "UMT";
int count = 0;

public:

Student()
{
count = count + 1;
}
void setstudent(string a, double b, string c);
void displaystudent();
void displayTotalStudent();

};
void Student::setstudent(string a, double b, string c)
{
Student_name = a;
CGPA = b;
Degree = c;
}
void Student::displaystudent()
{
cout << "Student name is :" << Student_name << endl;
cout << "Your CGPA is :" << CGPA << endl;
cout << "Your degree is :" << Degree << endl;
cout << "Your University is :" << x << endl;
}

void Student::displayTotalStudent()
{
count++;
cout << count << endl;
}

2
int main()
{
Student S1, S2, S3;
S1.setstudent(" Farooq Arshad ", 3.67, " BSCS ");
S2.setstudent(" Ali Amjad ", 2.89 , " BSIT ");
S3.setstudent(" Talha Ali ", 3.89 , " BSCS ");
S1.displaystudent();
S2.displaystudent();
S3.displaystudent();
return 0;

You might also like