Friday 1 February 2013

book detail and print expensive book in c++ by zafar iqbal levi

//PRINT DETAILS OF FIVE BOOKS AND ALSO DISPLAY THE BOOK HAVING HIGHEST PRICE
#include<iostream.h>
#include<conio.h>
class book
{
private:
int code,pages;
public:
int price;
void input()
{cout<<"enter code    ";
cin>>code;
cout<<"enter pages    ";
cin>>pages;
cout<<"enter price    ";
cin>>price;}
void output()
{cout<<"code=    "<<code<<endl;
cout<<"pages=    "<<pages<<endl;
cout<<"price=    "<<price<<endl;}
};
void main()
{book b1;
cout<<"\nEnter details for the first book\n\n";
b1.input();
book b2;
cout<<"\nEnter details for the 2nd book\n\n";
b2.input();
book b3;
cout<<"\nEnter details for the 3rd book\n\n";
b3.input();
book b4;
cout<<"\nEnter details for the fourth book\n\n";
b4.input();
book b5;
cout<<"\nEnter details for the fifth book\n\n";
b5.input();
cout<<"\nfirst book\n\n";
b1.output();
cout<<"\n2nd book\n\n";
b2.output();
cout<<"\n3rd book\n\n";
b3.output();
cout<<"\n4th book\n\n";
b4.output();
cout<<"\n5th book\n\n";
b5.output();
if(b1.price>b2.price&&b1.price>b3.price&&b1.price>b4.price&&b1.price>b5.price)
{cout<<"\nthe book having greatest price is\n\n";b1.output();}
else
if(b2.price>b1.price&&b2.price>b3.price&&b2.price>b4.price&&b2.price>b5.price)
{cout<<"\nthe book having greatest price is\n\n";
 b2.output();}
else      
if(b3.price>b1.price&&b3.price>b2.price&&b3.price>b4.price&&b3.price>b5.price)
{cout<<"\nthe book having greatest price is\n\n";
 b3.output();}
else
if(b4.price>b1.price&&b4.price>b2.price&&b4.price>b3.price&&b4.price>b5.price)
{cout<<"\nthe book having greatest price is\n\n";
 b4.output();}
else
if(b5.price>b1.price&&b5.price>b2.price&&b5.price>b3.price&&b5.price>b4.price)
{cout<<"\nthe book having greatest price is\n\n";
 b5.output();}
getch();}

0 comments:

Post a Comment