Skip to content

Commit d23e5d0

Browse files
committed
Rent Book Module#4
1 parent 735777e commit d23e5d0

File tree

2 files changed

+26
-34
lines changed

2 files changed

+26
-34
lines changed

Project-File/Library-Management-System.c

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ void addBook(){
605605
fflush(stdin);
606606

607607
char name[255], author[255], publisher[255];
608-
double bookid, quantity, price;
608+
double bookid, quantity;
609609

610610
FILE *pF = fopen("book_Records.txt", "ab+");
611611

@@ -628,10 +628,7 @@ void addBook(){
628628
printf("Enter Book Quantity: ");
629629
scanf("%lf",&quantity);
630630

631-
printf("Enter Book Price: ");
632-
scanf("%lf",&price);
633-
634-
fprintf(pF, "%s %s %s %.0lf %.0lf %.0lf \n", name, author, publisher, bookid, quantity, price);
631+
fprintf(pF, "%s %s %s %.0lf %.0lf \n", name, author, publisher, bookid, quantity);
635632

636633
printf("\n>>> Book Record Added Successfully <<< \n");
637634
}
@@ -672,10 +669,10 @@ void modifyBook(){
672669
fflush(stdin);
673670

674671
char name[255], author[255], publisher[255];
675-
double bookid, price, quantity;
672+
double bookid, quantity;
676673

677674
char name1[255], author1[255], publisher1[255];
678-
double bookid1, price1, quantity1;
675+
double bookid1, quantity1;
679676

680677
int flag=0;
681678
int compare;
@@ -689,7 +686,7 @@ void modifyBook(){
689686
FILE *pF = fopen("book_Records.txt", "r");
690687
FILE *pT = fopen("temporary.txt", "a");
691688

692-
while(fscanf(pF, "%s %s %s %lf %lf %lf \n", name, author, publisher, &bookid, &quantity, &price) != EOF)
689+
while(fscanf(pF, "%s %s %s %lf %lf \n", name, author, publisher, &bookid, &quantity) != EOF)
693690
{
694691
compare = strcmp(find, name);
695692

@@ -716,17 +713,14 @@ void modifyBook(){
716713
printf("> Enter Quantity: ");
717714
scanf("%lf",&quantity1);
718715

719-
printf("> Enter Price: ");
720-
scanf("%lf",&price1);
721-
722-
fprintf(pT, "%s %s %s %.0lf %.0lf %.0lf \n", name1, author1, publisher1, bookid1, quantity1, price1);
716+
fprintf(pT, "%s %s %s %.0lf %.0lf \n", name1, author1, publisher1, bookid1, quantity1);
723717
printf("\n\nProcessing your changes....");
724718

725719
flag = 1;
726720
}
727721
else
728722
{
729-
fprintf(pT, "%s %s %s %.0lf %.0lf %.0lf \n", name, author, publisher, bookid, quantity, price);
723+
fprintf(pT, "%s %s %s %.0lf %.0lf \n", name, author, publisher, bookid, quantity);
730724
}
731725
}
732726

@@ -749,9 +743,9 @@ void modifyBook(){
749743
pF = fopen("book_Records.txt", "a");
750744
pT = fopen("temporary.txt", "r");
751745

752-
while(fscanf(pT, "%s %s %s %lf %lf %lf \n", name, author, publisher, &bookid, &quantity, &price) != EOF)
746+
while(fscanf(pT, "%s %s %s %lf %lf \n", name, author, publisher, &bookid, &quantity) != EOF)
753747
{
754-
fprintf(pF, "%s %s %s %.0lf %.0lf %.0lf \n", name, author, publisher, bookid, quantity, price);
748+
fprintf(pF, "%s %s %s %.0lf %.0lf \n", name, author, publisher, bookid, quantity);
755749
}
756750

757751
fclose(pF);
@@ -770,20 +764,19 @@ void listBook(){
770764
fflush(stdin);
771765

772766
char name[255], author[255], publisher[255];
773-
double quantity, price, bookid;
767+
double quantity, bookid;
774768
int counter=0;
775769

776770
FILE *pF = fopen("book_Records.txt", "r");
777771

778-
while(fscanf(pF, "%s %s %s %lf %lf %lf \n", name, author, publisher, &bookid, &quantity, &price) != EOF)
772+
while(fscanf(pF, "%s %s %s %lf %lf \n", name, author, publisher, &bookid, &quantity) != EOF)
779773
{
780774
printf("-------------------------------\n");
781775
printf("> Book Name: %s \n", name);
782776
printf("> Auhtor: %s \n", author);
783777
printf("> Publisher: %s\n", publisher);
784778
printf("> Book ID: %.0lf \n", bookid);
785779
printf("> Quantity: %.0lf \n", quantity);
786-
printf("> Price: %.0lf \n", price);
787780
printf("-------------------------------\n\n\n");
788781
counter++;
789782
}
@@ -863,9 +856,9 @@ void rentBook(){
863856
printf("User Searcher: %d \n", nameFound);
864857
printf("Book Searcher: %d \n", bookFound);
865858

866-
// check if user has enough money for the book (book price)
859+
// check if user has enough money for the book (book price)
867860

868-
// global variables for storing records
861+
// global variables for storing records
869862

870863
// new rental file for data storing
871864
}
@@ -878,7 +871,7 @@ int searchBook(int bookSearcher){
878871
fflush(stdin);
879872

880873
char name[255], author[255], publisher[255];
881-
double bookid, price, quantity;
874+
double bookid, quantity;
882875

883876
int flag=0;
884877
int compare;
@@ -889,7 +882,7 @@ int searchBook(int bookSearcher){
889882

890883
FILE *pF = fopen("book_Records.txt", "r");
891884

892-
while(fscanf(pF, "%s %s %s %lf %lf %lf \n", name, author, publisher, &bookid, &quantity, &price) != EOF)
885+
while(fscanf(pF, "%s %s %s %lf %lf \n", name, author, publisher, &bookid, &quantity) != EOF)
893886
{
894887
compare = strcmp(find, name);
895888

@@ -907,7 +900,6 @@ int searchBook(int bookSearcher){
907900
printf("> Publisher: %s\n", publisher);
908901
printf("> Book ID: %.0lf \n", bookid);
909902
printf("> Quantity: %.0lf \n", quantity);
910-
printf("> Price: %.0lf \n", price);
911903
printf("-------------------------------\n\n");
912904
}
913905

@@ -944,10 +936,10 @@ void deleteBook(){
944936
fflush(stdin);
945937

946938
char name[255], author[255], publisher[255];
947-
double bookid, price, quantity;
939+
double bookid, quantity;
948940

949941
char name1[255], author1[255], publisher1[255];
950-
double bookid1, price1, quantity1;
942+
double bookid1, quantity1;
951943

952944
int flag=0;
953945
int compare;
@@ -961,7 +953,7 @@ void deleteBook(){
961953
FILE *pF = fopen("book_Records.txt", "r");
962954
FILE *pT = fopen("temporary.txt", "a");
963955

964-
while(fscanf(pF, "%s %s %s %lf %lf %lf \n", name, author, publisher, &bookid, &quantity, &price) != EOF)
956+
while(fscanf(pF, "%s %s %s %lf %lf \n", name, author, publisher, &bookid, &quantity) != EOF)
965957
{
966958
compare = strcmp(find, name);
967959

@@ -976,7 +968,7 @@ void deleteBook(){
976968
}
977969
else
978970
{
979-
fprintf(pT, "%s %s %s %.0lf %.0lf %.0lf \n", name, author, publisher, bookid, quantity, price);
971+
fprintf(pT, "%s %s %s %.0lf %.0lf \n", name, author, publisher, bookid, quantity);
980972
}
981973
}
982974

@@ -999,9 +991,9 @@ void deleteBook(){
999991
pF = fopen("book_Records.txt", "a");
1000992
pT = fopen("temporary.txt", "r");
1001993

1002-
while(fscanf(pT, "%s %s %s %lf %lf %lf \n", name, author, publisher, &bookid, &quantity, &price) != EOF)
994+
while(fscanf(pT, "%s %s %s %lf %lf \n", name, author, publisher, &bookid, &quantity) != EOF)
1003995
{
1004-
fprintf(pF, "%s %s %s %.0lf %.0lf %.0lf \n", name, author, publisher, bookid, quantity, price);
996+
fprintf(pF, "%s %s %s %.0lf %.0lf \n", name, author, publisher, bookid, quantity);
1005997
}
1006998

1007999
fclose(pF);

Project-File/book_Records.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
Dracula Willam Stanford 11 0 90
2-
Shogun James Standford 12 5 50
3-
Eillpsis Newton Oxford 13 15 110
4-
Candide Voltaire Nalanda 14 15 120
5-
Beloved Toni DTU 15 10 100
1+
Dracula Willam Stanford 11 0
2+
Shogun James Standford 12 10
3+
Eillpsis Newton Oxford 13 15
4+
Candide Voltaire Nalanda 14 15
5+
Beloved Toni DTU 15 10

0 commit comments

Comments
 (0)