Saturday, 21 January 2017

Illustration For Class with a simple book program in DEV C++ || CLASS Tutorial

//This Program Is Created BY MOHD. MUJTABA Follow &msg me On Instagram-iammujtaba_official
#include<iostream>
#include<conio.h>
#include<stdlib.h>
#include<stdio.h>
using namespace std;
int nob,i;
class book
{
      char bn[30],bt[20];
      int price,totcst,noc;
      int totcost()
       {
                     totcst=price*noc; 
                     return totcst;
                     }
      public:
             void input()
             {   fflush(stdin);
                  cout<<"Enter Book Name: ";
                  gets(bn);
                  fflush(stdin);
                  cout<<"Enter Author Name: ";
                  gets(bt);
                  fflush(stdin);
                  cout<<"Enter Price Of Books: ";
                  cin>>price;
                  }
             void purch()
             {
                cout<<"Enter Numeber Of Copies: ";
                cin>>noc;
                totcost();
               
                     }
                     void disp()
                     {
                          
                           cout<<"Book Name :"<<bn;
                           cout<<"\nAuthor Name :"<<bt;
                           cout<<"\n Price : Rs"<<price;
                           cout<<"\n Number Of Copies Of Book Present: "<<noc;
                           cout<<"\nTotal Pice: Rs"<<totcst;
                           }
             }b[10];
             main()
             {
                   cout<<"Enter Number Of Books you want to add:";
                   cin>>nob;
                   for(i=0;i<nob;i++)
                   {
                                    system("cls");
                                    cout<<"      Enter Details For Book:"<<i+1;
                                    cout<<"\n===============================\n\n";
                                     fflush(stdin);
                                     b[i].input();
                                     b[i].purch();
                                     }
                                     system("cls");
                                    cout<<"\n\n=================================\n  The Books Details Are......\n=================================\n";
                                     for(i=0;i<nob;i++)
                                     {
                                                       b[i].disp();
                                                       cout<<"\n=======================\n";
                                                       }
                                                       getch();
                                                      
                                     }
                                     //thanking you Please Share My Program and blog to help others....
                                     
             
             

No comments:

Post a Comment

Amazon1Ads