We have been working very hard since 2009 to facilitate in learning Read More. We can't keep up without your support. Donate.

CS304 Object Oriented Programming Assignment No 03 Fall 2020 Solution & Discussion

Views: 541

Replies to This Discussion

Share the Assignment Questions & Discuss Here.... 

Stay touched with this discussion, Solution idea will be uploaded as soon as possible in replies here before the due date.

CS304-Assignment NO 03 solution fall 2020

Click on the below link to download the file

CS304-Assignment No-3

CS304_Assignment_No_03_Solution_Fall_2020

Click on the below link to download the file

CS304_Assignment_No_03_Solution_Fall_2020

CS304 Assignment 3 Fall 2020 Solution idea:

 

Code:

#include<iostream>
#include <cstring>
#include <string>
using namespace std;

class Person
{
private :
string name;
int age;
string gender;
string address;
string phone;

public :
Person()
{

}

void set_name(string n)
{
name=n;
}
void set_age(int a)
{
age=a;
}
void set_gender(string g)
{
gender=g;
}
void set_address(string ad)
{
address=ad;
}
void set_phone(string p)
{
phone=p;
}

string get_name()
{
return name;
}
int get_age()
{
return age;
}
string get_gender()
{
return gender;
}
string get_address()
{
return address;
}
string get_phone()
{
return phone;
}

virtual void save_info()
{
cin.ignore();
cout"Enter Name : ";
getline(cin, name);
cout"Enter Gender : ";
cin>>gender;
cout"Enter Age : ";
cin>>age;
cin.ignore();
cout"Enter Address : ";
getline(cin, address);
cout"Enter Phone No : ";
cin>>phone;
}

virtual void display_info()
{
cout"Name : "name;
cout"\nGender : "gender;
cout"\nAge : "age;
cout"\nAddress : "address;
cout"\nPhone No. : "phone;
}
};

class Patient : public Person
{
private :
string sickness;
string prescription;
public :
Patient()
{

}

void save_info()
{
cout"\nEnter the following data for Patient\n\n";
Person::save_info();
cout"Enter Sickness : ";
cin>>sickness;
cout"Enter Prescription : ";
cin>>prescription;
}

void display_info()
{
cout"\nDisplaying Patient's Information:\n------------------------------------\n";
cout"\nPatient's Name : "get_name();
cout"\nPatient's Gender : "get_gender();
cout"\nPatient's Age : "get_age();
cout"\nPatient's Address : "get_address();
cout"\nPatient's Phone No. : "get_phone();
cout"\nPatient's Sickness : "sickness;
cout"\nPrescription for the sickness : " prescription;
}
};

class Staff : public Person
{

private :
string education;
long salary;

public :
Staff()
{

}

void save_info()
{
cout"\nEnter the following data for Staff\n\n";
Person::save_info();
cout"Enter Education : ";
cin>>education;
cout"Enter Salary : ";
cin>>salary;
}

void display_info()
{
cout"\nDisplaying Staff's Information:\n------------------------------------\n";
cout"\nStaff's Name : "get_name();
cout"\nStaff's Gender : "get_gender();
cout"\nStaff's Age : "get_age();
cout"\nStaff's Address : "get_address();
cout"\nStaff's Phone No. : "get_phone();
cout"\nStaff's Education : "education;
cout"\nStaff's Salary : " salary;
}
};

void showinfo()
{

}
main()
{
showinfo();
int number=0, i=0;
char type='\0', option='\0';
cout"How many Person's information you want to enter : ";
cin>>number;
Person * persons[number];
do
{
again:
cout"\nEnter choice: P for Patient, S for Staff : ";
cin>>type;
if(type=='p' || type=='P')
{
persons[i]=new Patient();
persons[i]->save_info();
i++;
}
else if(type=='s' || type=='S')
{
persons[i]=new Staff();
persons[i]->save_info();
i++;
}
else
{
cout"\nSorry Invalid Choice , Try Again\n";
goto again;
}
cout"Do you want to enter more data (Y for Yes N for No) : ";
cin>>option;
}while((option=='Y' || option=='y') && i<number);
for(int j=0; j<i; j++)
{
cout"\n";
persons[j]->display_info();
cout"\n------------------------------------";
}

cout"\n";
showinfo();
cout"\n\n";
}

cs304 assignment no 03 solution files in doc and cpp format.

CS304 Assignment No.3 2021

CS304_3_Sol_F20.txt

CS304-Assignment%20No-3.cpp

#CS304 #CS304Assignment3 #CS304AssignmentSolution
CS304 Assignment No. 3 Fall 2020 Solution

Cs304 Assignment No 3 Solution Fall 2020 Complete Correct Solved

CS304 assignment 3 solution 2021

CS304 assignment 3 solution 2021

Please downlaod .CPP file link available at the end of the page. 

#include <iostream>
#include <string>
using namespace std;

class StackItem{
private:
string ItemName;
string Course_Code;
string Course_Name;
int Price;
int Quantity;

public:
Stackitem()
{

}
void setItemName()
{
cout“\nPlease enter the name of item : “;
cin>>ItemName;
}

void setCourse_Code()
{
cout“\nPlease enter the course code : “;
cin>> Course_Code;
}

void setCourse_Name()
{
cout“\nPlease Enter the course name : “;
cin>> Course_Name;
}

void setPrice()
{
cout“\nPlease enter the item price : “;
cin>> Price;
}
void setQuantity()
{

cout“\nPlease enter the quantity of item : “;
cin>> Quantity;
}
string getItemName()
{
return ItemName;
}

string getCourse_Code()
{
return Course_Code;
}

string getCourse_Name()
{
return Course_Name;
}

int getPrice()
{
return Price;
}

int getQuantity()
{
return Quantity;
}

void display()
{

}

};
class Lecture_DVD:public StackItem{
private:
int TotalMins;
int TotalLec;
public:
Lecture_DVD()
{

}

void setTotalMins()
{
cout“\nPlease enter the total minutes of the vedio : “;
cin>>TotalMins;
}

void setTotalLec()
{
cout“\nPlease enter the total lectures : “;
cin>>TotalLec;
}

int getTotalMins()
{
return TotalMins;
}

int getTotalLec()
{
return TotalLec;
}
virtual void display()
{
cout“\nDisplaying Lecture DVD Information:”endl;
cout“………………………………….\n”;
cout“Item Name: “getItemName()endl;
cout“Course Name: “getCourse_Name()endl;
cout“Course Code: “getCourse_Code()endl;
cout“Quantity: “getQuantity()endl;
cout“Price: “getPrice()endl;
cout“Minutes: “getTotalMins()endl;
cout“Lectures: “getTotalLec()endl;
}

};

class Handouts:public StackItem{

private:
int No_Pages;
string Author;
public:
Handout()
{

}

void setNo_Pages()
{
cout“\nPlease enter Pages : “;
cin>> No_Pages;
}

void setAuthor()
{
cout“\nPlease enter the author : “;
cin>> Author;
}
int getNo_Pages()
{
return No_Pages;
}
string getAuthor()
{
return Author;
}
virtual void display()
{
cout“\nDisplaying Book Information:”endl;
cout“………………………………….\n”;
cout“Item Name: “getItemName()endl;
cout“Course Name: “getCourse_Name()endl;
cout“Course Code: “getCourse_Code()endl;
cout“Handout Quantity: “getQuantity()endl;
cout“Handout Price: “getPrice()endl;
cout“Handout Pages: “getNo_Pages()endl;
cout“Handout Author: “getAuthor()endl;
}
};

int main()

{
int size, i;
char arr[size], check;
Handouts handouts;
Lecture_DVD lecture_dvd;
cout“\nHow many items do you want to enter? “endl;
cin>>size;
while(i<size)
{

cout“\nEnter choice: H for Handouts, L for Lecture DVD: “endl;
cin>>arr[i];
if(arr[i] == ‘H’ || arr[i] == ‘h’)
{

cout“\nEnter following data for Handouts: “endl;
handouts.setItemName();
handouts.setQuantity();
handouts.setPrice();
handouts.setCourse_Name();
handouts.setCourse_Code();
handouts.setNo_Pages();
handouts.setAuthor();
}
if(arr[i]==’l’ || arr[i]== ‘L’ )
{

cout“\nEnter following data for Lecture DVD: “endl;
lecture_dvd.setItemName();
lecture_dvd.setQuantity();
lecture_dvd.setPrice();
lecture_dvd.setCourse_Name();
lecture_dvd.setCourse_Code();
lecture_dvd.setTotalMins();
lecture_dvd.setTotalLec();
}
cout“\nDo you want to enter more data (Y for yes, N for No): “;
cin>>check;
if(check==’n’ || check ==’N’ || i==size-1)
{
for (i=0; i<size; i++)
{

if(arr[i] ==’H’ || arr[i] == ‘h’)
{
handouts.display();

}
if(arr[i] == ‘L’ || arr[i] == ‘l’)
{
lecture_dvd.display();

}
}
}
i++;

}
}

CS304 assignment 3 solution 2021

Downlaod solution file

RSS

© 2021   Created by + M.Tariq Malik.   Powered by

Promote Us  |  Report an Issue  |  Privacy Policy  |  Terms of Service