CS304 Assignment 2 Solution Spring 2024

If you are looking for CS304 Assignment 2 Solution Spring 2024? then you are visiting the right page. Here is the CS304 Assignment 2 2024 Solution PDF, Word and CPP file.

CS304 Assignment 2 Solution Spring 2024

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

CS304 Assignment 2 Solution 2024

Now you can easily view CS304 Assignment 2 2024 solution. Click the download button to get the solution file for your mobile phone or computer. CS304 Gdb Solution Spring 2024

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  File

CS304 Assignment 2 Solution Spring 2024

 

 

DOWNLOAD PDF

DOWNLOAD CPP File

DOWNLOAD Word File

CS304 Assignment 2, CS304 Assignment 2 Solution, CS304 Assignment No 2 Solution Spring 2024, CS304 Assignment 2 Solution 2024 File, CS304 Correct Assignment Solution 2024, CS304 Assignment 2 2024 Solution PDF by VU Answer, Download CS304 Assignment 2 100% Correct Solution 2024. CS304 Quiz Solution Spring 2024. CS304 past paper Solution Spring 2024

Please Note:

  1. Don’t copy-paste the same answer.
  2. Make sure you can make some changes to your solution file before submitting it.
  3. Copy-paste solution will be marked zero.
  4. If you found any mistake then correct them and inform us.
  5. Before submitting an assignment check your assignment requirement file properly.

Leave a Reply

Your email address will not be published. Required fields are marked *