Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

Waleed Khan

01-133152-100

Assignment#04

#include<iostream>
#include<conio.h>
#include<string>
using namespace std;
class info
{
protected:
string Name;
string F_Name;
string CNIC;
public:

void input_1()
{
cout << "Name: ";
getline(cin, Name);
cout << "Father Name: ";
getline(cin, F_Name);
cout << "CNIC: ";
getline(cin, CNIC);
}
void Modify_1()
{
cout << "Name: ";
getline(cin, Name);
cout << "Father Name: ";
getline(cin, F_Name);
cout << "CNIC: ";
getline(cin, CNIC);
}
void show_1()
{
cout << "Name: " << Name << endl;
cout << "Father Name: " << F_Name << endl;
cout << "CNIC: " << CNIC << endl;
}

};
class Result
{
protected:
string Subject[2][5];
string Semester[2];
float GPA[2], CGPA = 0;
public:
void Input_2()
{
for (int a = 0; a < 2; a++)
{
cout << "Semester " << a + 1 << endl;
for (int i = 0; i < 5; i++)
{
cout << "Subject " << i + 1 << " ! ";
getline(cin, Subject[a][i]);

Waleed Khan
01-133152-100

Assignment#04
}
cout << "GPA: ";
cin >> GPA[a];
CGPA = CGPA + GPA[a];
cin.ignore();

void Modify_2()
{
for (int a = 0; a < 2; a++)
{
cout << "Semester " << a + 1 << endl;
for (int i = 0; i < 5; i++)
{
cout << "Subject " << i + 1 << " ! ";
getline(cin, Subject[a][i]);
}
cout << "GPA: ";
cin >> GPA[a];
cin.ignore();
CGPA = CGPA + GPA[a];
}

void Show_2()
{
for (int i = 0; i < 2; i++)
{
cout << "Semester " << i + 1 << endl;
for (int x = 0; x < 5; x++)
{
cout << "Subject " << i + 1 << "! " << Subject[i][x] << endl;
}
cout << "GPA: " << GPA[i] << endl;
}
cout << "CGPA! " << (CGPA / 2) << endl;
}
};
class Student :public info, public Result
{
private:
string Programe;
string St_ID;
int a;
public:
void Input_3()
{
info::input_1();
Result::Input_2();
cout << "Programe: ";
getline(cin, Programe);
cin.ignore();
cout << "ID: ";
getline(cin, St_ID);

Waleed Khan
01-133152-100

Assignment#04

}
void Modify_3()
{
cout << "Press 1 for Update Info: " << endl;
cout << "Press 2 for Update Result: " << endl;
cout << "Press 3 for Update Student: " << endl;
cin >> a;
if (a == 1)
{
info::Modify_1();
}
else if (a == 2)
{
Result::Modify_2();
}
else if (a == 3)
{
cout << "Programe: ";
getline(cin, Programe);
cout << "ID: ";
getline(cin, St_ID);
}
else
{
cout << "Plz Sellect Correct Command: ";
}
}
void Show_3()
{
info::show_1();
Result::Show_2();
cout << "Programe: " << Programe << endl;
cout << "ID: " << St_ID << endl;
}
};
void main()
{
int b;
Student s1[2];
for (int i = 0; i < 2; i++)
{
s1[i].Input_3();
}
cout << endl;
cout << "Press 1 For First student Modification: "<<endl;
cout << "Press 2 For Second student Modification: ";
cin >> b;
if (b == 1)
{
s1[1].Modify_3();
}
else if (b == 1)
{

Waleed Khan
01-133152-100
}
else
{

s1[2].Modify_3();

for (int i = 0; i < 2; i++)


{
s1[i].Show_3();
}
}

_getche();
system("cls");
main();

Assignment#04

Waleed Khan
01-133152-100

Assignment#04

You might also like