Oop Lab 7 Fa19-Bee-170
Oop Lab 7 Fa19-Bee-170
FA19-BEE-170
BEE-3D
OOP
LAB REPORT 7
TASK 1:
#include<iostream>
#include<conio.h>
#include<string>
using namespace std;
class publication {
string title;
int price;
public:
void getdata(){
cout << "\nEnter the title of the book: " << endl;
cin >> title;
cout << "\nEnter the price of the book:" <<
endl;
cin >> price;
}
void putdata(){
cout << "\nThe title of the book: " << title
<<endl;
cout << "The price of the book: " << price <<
endl;
}
};
class book : public publication {
int pages;
public:
void getdata(){
cout << "\nEnter the page count: " << endl;
cin >> pages;
}
void putdata(){
cout << "Number of pages: " << pages << endl;
}
};
class tape : public publication {
int time;
public:
void getdata(){
cout << "\nEnter the playing time in minutes: "
<< endl;
cin >> time;
}
void putdata(){
cout << "The playing time in minutes: " << time
<< endl;
}
};
int main ()
{
publication p1;
book b2;
tape t3;
p1.getdata();
b2.getdata();
t3.getdata();
p1.putdata();
b2.putdata();
t3.putdata();
return 0;
}
TASK 2:
#include<iostream>
#include<conio.h>
#include<string>
using namespace std;
class Person {
string ID;
string Name ,Address;
public:
void getdata(){
cout << "\nEnter The ID: " << endl;
cin >> ID;
cout << "\nEnter The Name: " << endl;
cin >> Name;
cout << "\nEnter The Address: " << endl;
cin >> Address;
}
void putdata(){
cout << "\nID: " << ID <<endl;
cout << "Name: " << Name << endl;
cout << "Address: " << Address << endl;
}
};
class Student : public Person {
int RollNumber,Marks;
public:
void getdata(){
cout << "\nEnter the Roll Number: " << endl;
cin >> RollNumber;
cout << "\nEnter the marks: " << endl;
cin >> Marks;
}
void putdata(){
cout << "Roll Number: " << RollNumber <<
"\nMarks: "<< Marks << endl;
}
};
int main ()
{
Person P1;
Student S1;
P1.getdata();
S1.getdata();
P1.putdata();
S1.putdata();
return 0;
}
TASK 3:
#include<iostream>
#include<conio.h>
#include<string>
using namespace std;
class Computer
{
int wordsize,memorysize,storagesize;
float speed;
public:
Computer() :
wordsize(0),memorysize(0),storagesize(0),spee
d(0){}
void getdata(){
cout << "\nEnter the Word Size in Bits: " <<
endl;
cin >> wordsize;
cout << "Enter the Memory Size in
MegaBytes(MB): " << endl;
cin >> memorysize;
cout << "Enter the Storage Size in
MegaBytes(MB): " << endl;
cin >> storagesize;
cout << "Enter the Speed in MegaHertz(MHz): "
<< endl;
cin >> speed;
}
void showdata(){
cout<<"Word Size: "<<wordsize <<" Bits"<<endl
<<"Memory Size: "<<memorysize<<"
MB"<<endl<<"Storage Size: "<<storagesize<<"
MB"<<endl<<"Speed: "<<speed<<"
MHz"<<endl;
}
};
class Laptop : public Computer
{
float length,width,height,weight;
public:
Laptop():length(0), width(0), height(0)
,weight(0){
}
void getdata(){
cout<<"\nEnter The Length: "<< endl;
cin>>length;
cout<<"Enter The Width: "<< endl;
cin>>width;
cout<<"Enter The Height: "<< endl;
cin>>height;
cout <<"Enter The Weight: "<< endl;
cin >> weight;
}
void showdata(){
cout<<"Length: "<<length<<endl<<"Width:
"<<width<<endl<<"Height:
"<<height<<endl<<"Weight: "<<weight<<endl;
}
};
int main ()
{
Computer C1;
Laptop L1;
C1.getdata();
L1.getdata();
cout<<endl;
C1.showdata();
L1.showdata();
return 0;
}
HOME TASKS 1:
#include<iostream>
#include<string>
using namespace std;
class Student{
protected:
int rollno;
string name;
public:
void getdata(){
cout <<"\nEnter your Roll No: ";
cin >> rollno;
Tmarks=((T1marks+T2marks+T3marks)/30)*15;
sum=Tmarks+Assignment+Sessional1+Sessional
2;
percentage1=(sum/50)*100;
percentage2=(Final/50)*100;
result=(percentage1+percentage2)/2;
cout <<"Final result: "<<result<<"%";
}
};
int main(){
Student S1; Test T1; S1.getdata();
T1.getmarks();
cout<<endl<<endl;
S1.putdata(); T1.putmarks();
T1.Finalresult();
}
HOME TASK 2:
#include<iostream>
#include<string>
using namespace std;
class Simple
{
protected:
float num1,num2;
float
addition,subtraction,multiplication,division;
public:
float getdata(){
cout <<"\nEnter Numumber 1: ";
cin >> num1;