C++ Programme using class serial to store and display serial's title,duration, number of episodes, serial code



#include<iostream.h>
#include<conio.h>
#include<stdio.h>
class serial
{
               int code;
               char title[20];
               float duration;
               int noe;
               public:
               serial()
               {
                              duration=30;
                              noe=103;
               }
               void newserial();
               void otherentries(int dur,int no);
               void displaydata();
};


void serial::newserial()
{
               cout<<"\n\nEnter the serial code:";
               cin>>code;
               cout<<"Enter the title:";
               gets(title);
}


void serial::otherentries(int dur,int no)
{
               duration=dur;
               noe=no;
}


void serial::displaydata()
{
               cout<<"\tSerial code is:"<<code<<endl;
               cout<<"\tTitle is:"<<title<<endl;
               cout<<"\tDurations is:"<<duration<<endl;
               cout<<"\tNo. of episodes are:"<<noe<<endl<<endl;
}


int main()
{
               clrscr();
               char ch='y';
               int i=0,dur,no;
               serial s1[10];
               while(ch=='y')
               {
                              s1[i].newserial();
                              cout<<"Enter the duration and the no. of episodes:";
                              cin>>dur>>no;
                              s1[i].otherentries(dur,no);
                              i++;
                              cout<<"\n\nDo you want to continue:";
                              cin>>ch;
               }
               cout<<"\n\nThe details you have entered are:"<<endl<<endl;
               for(int j=0;j<i;j++){
                              cout<<"Data of serial "<<j+1<<" is:"<<endl;
                              s1[j].displaydata();
               }
               return 0;
}

OUTPUT:
Enter the serial code:121
Enter the title:DaVinciCode
Enter the duration and the no. of episodes:30 50


Do you want to continue:y


Enter the serial code:122
Enter the title:solomon
Enter the duration and the no. of episodes:60 20


Do you want to continue:n


The details you have entered are:

Data of serial 1 is:
               Serial code is:121
               Title is:DaVinciCode
               Durations is:30
               No. of episodes are:50

Data of serial 2 is:
               Serial code is:122
               Title is:solomon
               Durations is:60
               No. of episodes are:20

No comments:

Post a Comment