# CS304 Assignment 2 Solution Spring 2022 - Correct Code VU Answer

If you are looking for CS304 Assignment 2 Solution 2022 Spring? then you visit the right site. Here is CS304 Assignment 2 2022 Solution PDF, Word and CPP File.

## CS304 Assignment 2 Solution Spring 2022

Dear VU Students, in this post you can easily read or download CS304 Assignment 2 Solution Spring 2022 PDF. CS304 Assignment 2 Solution 2022 File.

See Also Important Materials:

CS101 Assignment 2 Solution 2022 File - DOWNLOAD

CS507 Assignment 2 Solution 2022 - DOWNLOAD

CS304 Finalterm Solved Papers by Waqar Siddhu - DOWNLOAD

CS304 Short Notes - DOWNLOAD

CS304 Highlighted Handouts PDF - DOWNLOAD

### CS304 Assignment 2 Solution 2022

Now you can easily view the solution CS304 Assignment 2 2022 provided by VU Answer. Click on the download button to get the solution file is your Mobile or PC.

CODE Solution:

CODE Solution

#include <iostream>

#include <string>

using namespace std;

class Person{

string name;

char gender;

int age;

public:

Person(string n, char g, int ag){

setName(n);

setGender(g);

setAge(ag);

}

//setters functions

void setName(string nam){

name = nam;

}

void setGender(char g){

gender = g;

}

void setAge(int ag){

age = ag;

}

//getters functions

string getName(){

return name;

}

char getGender(){

return gender;

}

int getAge(){

return age;

}

virtual void displayData() = 0;

};

class Student : public Person {

string studentId;

string degreeProgram;

float feePerSem;

public:

Student(string name, char gender, int age, string id, string degProg, float semFee) :Person(name, gender, age){

setId(id);

setDegreeProgram(degProg);

setSemmesterFee(semFee);

}

//setter functions

void setId(string id){

studentId = id;

}

void setDegreeProgram(string program){

degreeProgram = program;

}

void setSemmesterFee(float fee){

feePerSem = fee;

}

//getter functions

string getId(){

return studentId;

}

string getDegreeProgram(){

return degreeProgram;

}

float getSemmesterFee(){

return feePerSem;

}

void displayData(){

cout<<"---------------------------------------------"<<endl;

cout<<"----------------Student Record---------------"<<endl;

cout<<"---------------------------------------------"<<endl<<endl;

cout<<"Name: "<<getName()<<endl;

cout<<"Gender: "<<getGender()<<endl;

cout<<"Age: "<<getAge()<<endl;

cout<<"Student Id: "<<getId()<<endl;

cout<<"Degree Program: "<<getDegreeProgram()<<endl;

cout<<"Fee Per Semmester: "<<getSemmesterFee()<<endl;

cout<<"---------------------------------------------"<<endl<<endl;

}

};

class Teacher : public Person {

float salary;

int allocatedStudents;

public:

Teacher(string name, char gender, int age, int allocStd, float salary): Person(name, gender, age){

setSalary(salary);

setAllacatedStudents(allocStd);

}

//setter functions

setSalary(float sal){

salary = sal;

}

setAllacatedStudents(int stdAlloc){

allocatedStudents = stdAlloc;

}

//getter functions

getSalary(){

return salary;

}

getAllacatedStudents(){

allocatedStudents;

}

void displayData(){

cout<<"---------------------------------------------"<<endl;

cout<<"----------------Teacher Record---------------"<<endl;

cout<<"---------------------------------------------"<<endl<<endl;

cout<<"Name: "<<getName()<<endl;

cout<<"Gender: "<<getGender()<<endl;

cout<<"No. of Allocated Students: "<<getAllacatedStudents()<<endl;

cout<<"Salary: "<<getSalary()<<endl;

cout<<"---------------------------------------------"<<endl;

}

};

int main(){

int totalPersons = 2;

Person *p[totalPersons];

Student std("Samra", 'f', 27, "BC000000", "BSCS", 22000); // Student ID and Name

Teacher techr("Zubair", 'm',  32, 22, 30000);

p[0] = &std;

p[1] = &techr;

for(int i = 0; i < totalPersons; i++){

p[i]->displayData();

}

}

CODE OUTPUT SCREENSHOT

DOWNLOAD CS304 Assignment 2 Solution Spring 2022 File

Hint: Easily directly download this file from your PC/laptop with just one click.

 File Name Download Link CS304 Assignment 2 Solution Spring 2022 DOWNLOAD CPP FileDOWNLOAD Word File

Check Also Important Below Links

All Assignment Solution Spring 2022 Files

All VU GDB Solution Spring 2022

Please Note:

Don't copy-paste the same answer.

Make sure you can make some changes to your solution file before submitting it.

Copy-paste solution will be marked zero.

If you found any mistake then correct them and inform us.

Before submitting an assignment check your assignment requirement file properly.

Tags: CS304 Assignment 2, CS304 Assignment 2 Solution, CS304 Assignment No 2 Solution Spring 2022, CS304 Assignment 2 Solution 2022 File, CS304 Correct Assignment Solution 2022, CS304 Assignment 2 2022 Solution PDF by VU Answer, Download CS304 Assignment 2 100% Correct Solution 2022.

Also, you can share it with your friends and share experiences with us through comment and social media. We will review your suggestions carefully.