check home phone-call search send

سورس کد برنامه کتابخانه به زبان سی پلاس پلاس

سورس کد برنامه کتابخانه به زبان سی پلاس پلاسسورس کد برنامه کتابخانه به زبان سی پلاس پلاس

در این پست سورس کد برنامه کتابخانه به زبان سی پلاس پلاس را برایتان آماده کرده ایم.این پروژه به زبان سی پلاس پلاس برنامه نویسی شده است که جنبه آموزشی و سرگرمی دارد و می توانید به عنوان یک پروژه آموزشی از آن استفاده کنیم.بعلاوه می توانید سورس کد پروژه حقوق و دستمزد به زبان سی پلاس پلاس را نیز از سایت دریافت کنید.

#include<iostream.h>
#include<stdlib.h>
#include<conio.h>
#include<string.h>
#define SIZE 5
//-------------class
class book
{

public:
//-------------tavabe
book();
void enter();
char getState();
void print();
//-------------khososiat
int id;
int price;
long date;

char name[10];
char author[10];
char category[10];
//---------------------------
};

book::book()
{
id=0;
price=0;
date=0;
name[0]='\0';
author[0]='\0';
category[0]='\0';
}
//-------------------------------------

void book::enter()
{
  clrscr();

  cout <<"Name : ";
  cin >>name;
  
  cout<< "id : ";
  cin >>id;
  
  cout<<"author : ";
  cin >>author;
  
  cout<<"category : ";
  cin >>category;
  
  cout<<"date : ";
  cin>>date;
  
  cout<<"price : ";
  cin>>price;
}
//-------------------------------------

void book::print()
{
   cout << id<<"\t"<< name<<"\t\t"<< author<<"\t\t"<<category<<"\t\t"<<price<<"\t"<<date<<endl;
}
//-------------------------------------

char book::getState()
{
  return name[0];
}
//--------------------------------------

//*******************************************************************************************
book b[SIZE];
int menu();
int FindIndex();
void report();
int reportid(long id);
void editid(long id);
void deleteid(long id);
void reportname(char name[10]);
void reportcategory(char catname[10]);
void reportdate(long start,long end);

//--------------program
void main()
{
int i,c,id;
long s,e;
char catname[10],name[10];
   for(;;) {
      clrscr();
      c = menu();
      switch (c) {
	    case 1 :
					i=FindIndex();
					if (i!=-1 )
					{
					b[i].enter();
					}
					else
					{
						cout << "\n List is full. press a key...";
						getch();
					}
	    break;
		case 2 :
	    clrscr();
		cout<<"Enter ID : ";
		cin>>id;
	    reportid(id);
	    
	        break;
	    case 3 :
	    clrscr();
		cout<<"Enter Name : ";
		cin>>name;
	    reportname(name);
	        break;
	    case 4 :
		 clrscr();
		 cout<<"Enter Category : ";
			cin>>catname;
	        reportcategory(catname);
	        break;
	    case 5 :
	        report();
	        break;
	    case 6 :
		 clrscr();
		 cout<<"Enter Start Of Period : ";
			cin>>s;
			cout<<"Enter End Of Period : ";
			cin>>e;
	        reportdate(s,e);
			case 7 :
	    clrscr();
		cout<<"Enter ID For Edit : ";
		cin>>id;
	    editid(id);
	    
	        break;
		case 8 :
	    clrscr();
		cout<<"Enter ID  For Delete From List : ";
		cin>>id;
	    deleteid(id);
		break;
			case 9 :
	        exit(0) ;
		} // end of switch
   } //end of for(;;)
clrscr();
cout<<"----";


getch();
getch();
}
//----------------tavabe program
int menu()
{
  int c;
  gotoxy(5, 5);
  cout << "1) Enter a Book.";
  gotoxy(5, 6);
  cout << "2) Search By ID.";
  gotoxy(5, 7);
  cout << "3) Search By Name.";
  gotoxy(5, 8);
  cout << "4) Search By Category.";
  gotoxy(5, 9);
  cout << "5) Report list.";
  gotoxy(5, 10);
  cout << "6) Caculate Total Price In Period.";  
  gotoxy(5, 11);
  cout << "7) Edit Book.";    
  gotoxy(5, 12);
  cout << "8) Delete Book.";  
  gotoxy(5, 13);
  cout << "9) Exit.";
  
  do {
     gotoxy(5, 15);
     cout << "Enter your select(1 - 9) : ";
     cin >> c;
  } while (c < 1 && c >9 );
  return c;
}

//------------------get index
int FindIndex()
{
  int index;
  for(index = 0; index < SIZE && b[index].getState(); index++);
  if(index == SIZE)
    return -1;
  return index;
}
//----------------------------

void report()
{
  int i;
  clrscr();
  cout <<"id"<<"\t"<<"name"<<"\t\t"<<"author"<<"\t\t"<<"category"<<"\t"<<"price"<<"\t"<<"date"<<endl;
  for(i = 0; i < SIZE; i ++) {
    if(b[i].getState())
       b[i].print();
  }
  getch();
}
//-------------------------------

void reportcategory(char catname[10])
{
  int i;
  clrscr();
  cout <<"id"<<"\t"<<"name"<<"\t\t"<<"author"<<"\t\t"<<"category"<<"\t"<<"price"<<"\t"<<"date"<<endl;
  for(i = 0; i < SIZE; i ++) {
    if(b[i].getState())
	if( strcmp(b[i].category,catname)==0)
       b[i].print();
  }
  getch();
}
//----------------------------------------

void reportname(char name[10])
{
  int i;
  clrscr();
  cout <<"id"<<"\t"<<"name"<<"\t\t"<<"author"<<"\t\t"<<"category"<<"\t"<<"price"<<"\t"<<"date"<<endl;
  for(i = 0; i < SIZE; i ++) {
    if(b[i].getState())
	if( strcmp(b[i].name,name)==0)
       b[i].print();
  }
  getch();
}
//---------------------------------------------
void editid(long id)
{
  int i;
  clrscr();
  if ( reportid(id)==-1)
  return ;
  
  for(i = 0; i < SIZE; i ++) {
    if(b[i].getState())
	if(b[i].id==id)
       b[i].enter();
  }
  getch();
}

//---------------------------------------------
void deleteid(long id)
{
  int i;
  clrscr();
  if ( reportid(id)==-1)
  return ;
  
    b[i].name[0]='\0';
  getch();
}

//---------------------------------------------
int reportid(long id)
{
  int i;
  clrscr();
  cout <<"id"<<"\t"<<"name"<<"\t\t"<<"author"<<"\t\t"<<"category"<<"\t"<<"price"<<"\t"<<"date"<<endl;
  for(i = 0; i < SIZE; i ++) 
  {
    if(b[i].getState())
	if(b[i].id==id)
       b[i].print();
	   
	   if(i==SIZE)
	   {
	   clrscr();
	   cout <<"Not Found";
	   return -1;
	   
	   }
	   
  }
  getch();
  return 1;
}
//------------------------------------------------

void reportdate(long start,long end)
{
  int i;
  long total=0;
  clrscr();
  cout <<"id"<<"\t"<<"name"<<"\t\t"<<"author"<<"\t\t"<<"category"<<"\t"<<"price"<<"\t"<<"date"<<endl;
  for(i = 0; i < SIZE; i ++) {
    if(b[i].getState())
	if( b[i].date>=start && b[i].date<=end)
       {
	   b[i].print();
	   total+=b[i].price;
	   }
  }
  cout <<"Total Cost From "<<start<<" To "<<end<<" : "<<total<<endl;
  getch();
}

 

دانلــود بـاکـــس

لینک های دانلود در این باکس قرار دارد
img

جهت مشاهده لینک های دانلود ابتدا وارد شده یا ثبت نام کنید

Avatar
پشتیبان سورس ایران 2180 مطلب منتشر شده

در مجموعه سورس ایران سعی می کنیم علاوه بر آموزش برنامه نویسی، به مسائل مرتبط و مهارت های نرم بپردازیم تا بعدهای مختلف را پوشش دهیم.

دیدگاه کاربران

تعداد دیدگاه های کاربران : ۰ دیدگاه
هنوز دیدگاهی ارسال نشده است.


شما با موفقیت در خبرنامه ما عضو شدید