کمک فوری برای ساخت برنامه مدیریت کتابخانه

vafajj

New Member
سلام
برای پروژه پایانی درس مبانی کامپیوتر یک برنامه مدیرت کتابخانه خانگی نوشتم یه چنتا اشکال جزئی داره که کلی گیجم کرده وقت زیادی ندارم دوشنبه باید تحویل بدم ممنون میشم کمکم کنید. با تشکر
اینم سرس برنام
#include <stdio.h>
#include <conio.h>
#include <iostream.h>
#include <stdlib.h>
#include <string.h>
//#include <dos.h>

#define M 50
int mainmenu(); //main menu
void blank(); //get blank all fields
void add(); //add book
int removemenu();
void removename(); //remove a book
void removeisbn(); //remove a book
int querymenu();
void showall();
void showname();
void showauthor();
void showisbn();
void showprice();
void about();
struct lib{
char name[101];
char author[51];
int no;
int price;} s[M];

///////////////main function//////
int main(){



int a,b,c;
blank();
for(;;){
system("cls");
a=mainmenu();
switch(a){
case 1: add(); break;
case 2: b=removemenu(); break;
case 3: c=querymenu(); break;
case 4: about(); break;
case 5: exit(0); break;
case 6: removename(); break;
case 7: removeisbn(); break;
case 8: mainmenu(); break;
case 9: showall(); break;
case 10: showname(); break;
case 11: showauthor(); break;
case 12: showisbn(); break;
case 13: showprice(); break;
case 14: mainmenu(); break; } //end of switch
switch(b){
case 6: removename(); break;
case 7: removeisbn(); break;
case 8: mainmenu(); break;}
switch(c){
case 9: showall(); break;
case 10: showname(); break;
case 11: showauthor(); break;
case 12: showisbn(); break;
case 13: showprice(); break;
case 14: mainmenu(); break; }
} //end of for
getch();
return 0;}
//////end of main function//////////
///mainmenu
int mainmenu(){
int a;
system("cls");
printf("\n main menu");
printf("\n1) Add a new book");
printf("\n2) Remove a book");
printf("\n3) Get query from books");
printf("\n4) About");
printf("\n5) Exit");
printf("\n\n Enter your choice:");
scanf("%d",&a);
return a;}
/////end of mainmenu
///removemenu
int removemenu(){
int a;
system("cls");
printf("\n Remove menu");
printf("\nselect one of these for remove:");
printf("\n1) Book name");
printf("\n2) Book ISBN");
printf("\n3) Back to main menu");
printf("\n\n Enter your choice:");
scanf("d",&a);
getch();
return a;}
////end of removemenu
///querymenu
int querymenu(){
int a;
system("cls");
printf("\n Query menu");
printf("\nselect one of these for remove:");
printf("\n1) show all books");
printf("\n2) search a specific book by name");
printf("\n3) search a specific book by author");
printf("\n4) search a specific book by ISBN");
printf("\n5) show the expenses of all books");
printf("\n6) Back to main menu");
printf("\n\n Enter your choice:");
scanf("d",&a);
a=getch();
return a+8;}
///end of querymenu
///blank
void blank(){
int i;
for(i=0;i<M;i++){
s.name[0]='\0';
s.author[0]='\0';
s.no=0;
s.price=0;}
}
///end of blank
///add
void add(){
system("cls");
int i,b;
for(i=0;i<M;i++){
if(s.name[0]=='\0')
b=i;
break;}
printf("\nBook name:");
scanf("%s",&s.name);
printf("\nBook's author name:");
scanf("%s",&s.author);
printf("\nBook's ISBN:");
scanf("%d",&s.no);
printf("\nBook's price:");
scanf("%d",&s.price);
}
//end of add
///removename
void removename(){
system("cls");
int i,count=0;
char string[101];
printf("enter a name for delete:");
cin.get(string,100);
for(i=0;i<M;i++)
if(strcmp(string,s.name)==0)
count++;
if(count==0)
printf("This book doesn't exist");
else
printf("this book removed");

for(i=0;i<M;i++)
if(strcmp(string,s.name)==0){
s.name[0]='\0';
s.author[0]='\0';
s.no=0;
s.price=0;}

}
///end of removename
///removeisbn
void removeisbn(){
system("cls");
int i,x,count=0;
printf("enter ISBN for delete:");
scanf("%d",&x);
for(i=0;i<M;i++)
if(x==s.no)
count++;
if(count==0)
printf("This book doesn't exist");
else
printf("this book removed");

for(i=0;i<M;i++)
if(x==s.no){
s.name[0]='\0';
s.author[0]='\0';
s.no=0;
s.price=0;}
getch();
}
///end of removeisbn
///showall
void showall(){
system("cls");
int i,a;
for(i=0;i<M;i++){
if(s.name[0]=='\0')
a=i;
break;}
printf(" name author ISBN price");
for(i=0;i<a;i++){
printf("%s %s %d %d",s.name,s.author,s.no,s.price);}
getch();
}
///end of showall
///showname
void showname(){
system("cls");
int i,x=0;
char string[101];
printf("enter a book name to search:");
cin.get(string,100);
for(i=0;i<M;i++)
if(strcmp(string,s.name)==0)
x=1;
if(x==1)
cout<<"the name "<<(string)<<" is exist";
else
cout<<"the name "<<(string)<<" is not exist";
getch();
}
///end of showname
///showauthor
void showauthor(){
system("cls");
int i,x=0;
char string[101];
printf("enter book's author to search:");
cin.get(string,100);
for(i=0;i<M;i++)
if(strcmp(string,s.author)==0)
x=1;
if(x==1)
cout<<"the name "<<(string)<<" is exist";
else
cout<<"the name "<<(string)<<" is not exist";
getch();
}
///end of showauthor
///showisbn
void showisbn(){
system("cls");
int i,x,z,a=0;
printf("enter ISBN for search:");
scanf("%d",&x);
for(i=0;i<M;i++)
if(x==s.no){
z=i;
a=1;}
if(a==1){
printf(" name author ISBN price");
printf("%s %s %d %d",s[z].name,s[z].author,s[z].no,s[z].price);}
else
cout<<"the ISBN "<<(x)<<" is not exist";
getch();
}
///end of showisbn
///showprice
void showprice(){
system("cls");
int i,sum=0;
for(i=0;i<M;i++)
sum=sum+s.price;
printf("all expenses for books is:%d",sum);
getch();
}
///end of showprice
///about
void about(){
system("cls");
printf("\n\t about library managment");
printf("\n\n\n\n\n\t");
printf("This program produced by:Vafajj");
getch();
}
///end of about
////////////////////////////////////////////enf of program//////////////////////////
 

پیوست ها

  • library.zip
    1.6 کیلوبایت · بازدیدها: 11

جدیدترین ارسال ها

بالا