//Program : Part A-5
//Write a object oriented program in c++ to create a library information system //containing the following for a book in the library : Accession number, Author //name, Title of the book, Year of publication, Publisher’s name, Cost of the book. //Define a class with data members and suitable member function for initializing //and for destroying the data viz constructor, destructor.
//Name:LDK E-NOTES Reg.No.:**********
#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
#include<string.h>
class library
{
int acno;
char aname[25];
char title[30];
int year;
char pub[30];
float cost;
public:
library(int a,char name[],char t[],int y,char p[],float c)
{
acno=a;
strcpy(aname,name);
strcpy(title,t);
year=y;
strcpy(pub,p);
cost=c;
}
void display(void)
{
cout<<"Accession No = "<<acno<<endl;
cout<<"Name = "<<aname<<endl;
cout<<"Title = "<<title<<endl;
cout<<"Year = "<<year<<endl;
cout<<"Publications = "<<pub<<endl;
cout<<"Price = "<<cost<<endl;
}
~library()
{
cout<<"\nData Memebers Deleted";
}
};
void main()
{
int a;
char name[25];
char t[30];
int y;
char p[30];
float c;
clrscr();
cout<<"Enter accession no : ";
cin>>a;
cout<<"Enter name : ";
cin>>name;
cout<<"Enter title : ";
cin>>t;
cout<<"Enter year : ";
cin>>y;
cout<<"Enter publications : ";
cin>>p;
cout<<"Enter price : ";
cin>>c;
library lib(a,name,t,y,p,c);
cout<<"\nBook Information\n";
lib.display();
}
Output 1 :
Enter accession no : 101
Enter name : Ivan
Enter title : Database
Enter year : 2007
Enter publications : ITC
Enter price : 275.50
Book Information
Accession No = 101
Name = Ivan
Title = Database
Year = 2007
Publications = ITC
Price = 275.50
Data Memebers Deleted
Output 2 :
Enter accession no : 102
Enter name : Robert
Enter title : C++
Enter year : 2006
Enter publications : Galgotia
Enter price : 350.75
Book Information
Accession No = 102
Name = Robert
Title = C++
Year = 2006
Publications = Galgotia
Price = 350.75
Data Memebers Deleted
No comments:
Post a Comment