Subscribe Us

Responsive Advertisement

Advertisement

 

E.balagurusamy 6.3 oop solution

by ujjal roy




#include<bits/stdc++.h>

using namespace std;

class book_shop

{

    string *author;

    string *title;

    double *price;

    string *publisher;

    int *copys;

public :

      book_shop(string title1)

     {

         author=new string[5];

         title=new string[5];

         price=new double[5];

         publisher=new string[5];

         copys=new int[5];

             author[0]="balaguru";

             title[0]="ANSIC";

             price[0]=500;

             publisher[0]="alpha";

             copys[0]=50;

             author[1]="balaguru";

             title[1]="OPP";

             price[1]=500;

             publisher[1]="alpha";

             copys[1]=50;

             author[2]="balaguru";

             title[2]="exercise";

             price[2]=500;

             publisher[2]="alpha";

             copys[2]=50;

             author[3]="kaykobad";

             title[3]="c_progrmming";

             price[3]=500;

             publisher[3]="alpha";

             copys[3]=50;

             author[4]="subin";

             title[4]="C";

             price[4]=500;

             publisher[4]="alpha";

             copys[4]=50;


   


     }

    void create(string title1 , string author1)

    {

        int c=0,i,p;

       for(i=0;i<5;i++)

       {

           if(title1==title[i]&&author1==author[i])

           {

               c=1;

               p=i;

               break;

           }


       }

         if(c)

           {

             cout<<"author : "<<author[p]<<"\ntitle :"<<title[p]<<endl;

             cout<<"price : "<<price[p]<<"\npublisher :"<<publisher[p]<<endl;

             cout<<"available : "<<copys[p]<<endl;

             cout<<"\nHow many copys you want : ";

             int co;

             cin>>co;

             if(co<=copys[p])

             {

                 double total=co*price[p];

                 cout<<"total price : "<<total<<endl;

             }

             else cout<<"sorry.out of stoke\n";

           }

           else

           {

               cout<<"Not found\n";

           }

    }




};

int main()

{


   string s,s1;

   cout<<"enter title :";

   cin>>s;

   cout<<"enter author :";

   cin>>s1;

     book_shop bs(s);

   bs.create(s,s1);

    return 0;

}


Post a Comment

0 Comments