Skillrack CSE1002 Inlab 7

Skillrack CSE1002 Inlab 7

Total time : 20 mins
Challenges : 1

Question (Price of books and CD/DVD)

Solution

#include<iostream>
using namespace std;
class learning_Material
{
protected :
char isbn[15];
char title[20];
char author[20];
int year;
float price;
public :
void get();
void print();
};
void learning_Material :: get(){}
void learning_Material :: print()
{
 cout<<isbn<<"\n"<<title<<"\n"<<price;
} 
class book : public learning_Material 
{ 
 public : 
  int pages; 
  void get() 
  { 
   cin>>isbn>>title>>author>>year>>pages;
  }
  void calc_Price()
  {
   price=pages;
  }
};
class CD : public learning_Material
{
 public :
  int time;
  void get()
  {
   cin>>isbn>>title>>author>>year>>time;
  }
  void calc_Price()
  {
   price=2*time;
  }
};
int main()
{
int ch;
cin>>ch;
if(ch==0)
{
book a;
a.get();
a.calc_Price();
a.print();
}
else
{
CD e;
e.get();
e.calc_Price();
e.print();
}
}
Share on Google Plus

About Unknown

This blog is exclusively for VITIAN'S TO fulfill their needs. Also you can tell our team your need and we will assist you as soon as possible. For any quaries send your emails to "everything4vitians@gmail.com". Thank you
    Blogger Comment

0 comments:

Post a Comment