Assignment 2: Question No 1 (20 Marks)
Assignment 2: Question No 1 (20 Marks)
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.
)
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;