Sunday, July 4, 2010

PUBLICATION DETAILS

Buzz It
/*PROGRAM TO READ AND DISPLAY PUBLICATION DETAILS
USING INHERITANCE */


#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdio.h>
class book
{
protected:
char name[25],author[25],pub[25],type[25];
int pgno;
public:
void read();
void display();
};
void book::read()
{
cout<<"ENTER THE DETAILS OF BOOK\n";
cout<<"----------------------------";
cout<<"\nEnter the Book Name:";
gets(name);
cout<<"\nEnter the name of Author:";
gets(author);
cout<<"\nEnter the name of Publication:";
gets(pub);
cout<<"\nEnter the type of Book:";
gets(type);
cout<<"\nEnter the page no:";
cin>>pgno;
}
void book::display()
{
cout<<"\nPUBLICATION DETAILS\n";
cout<<"---------------------------";
cout<<"\nName:\t\t"<<name;
cout<<"\nAuthor:\t\t"<<author;
cout<<"\nPublication:\t"<<pub;
cout<<"\nType :\t\t"<<type;
cout<<"\npageno:\t\t"<<pgno;
}
class price:public book
{float price,disc,org;
public:
void readp();
void calc();
void dis();
};
void price::readp()
{
cout<<"\nEnter the original price:";
cin>>org;
cout<<"\nEnter the discount:";
cin>>disc;
}
void price::calc()
{
price =org-(disc/100*org);
}
void price::dis()
{
cout<<"\nPrice:\t\t"<<price;
}
void main()
{
char ch;
price p;
clrscr();
do
{
p.read();
p.readp();
p.calc();
p.display();
p.dis();
cout<<"\nDo You Want to Continue?";
cout<<"\nY or N";
cin>>ch;
}
while(ch=='y'ch=='Y');
getch();
}

OUTPUT:
ENTER THE DETAILS OF BOOK
-------------------------
Enter the Book Name:Merchant of Venice
Enter the name of Author:Shakesphere
Enter the name of Publication:ABC publications
Enter the type of Book:Shortstory
Enter the page no:78
Enter the original price:100
Enter the discount:5
PUBLICATION DETAILS
---------------------------
Name: Merchant of venice
Author: Shakesphere
Publication: ABC publication
Type: Shortstory
Price: 95
Do you want to continue?
Y or N
N

0 comments:

Post a Comment