Question

// C programming Create a system managing a mini library system. Ev

0 0
Add a comment Improve this question Transcribed image text
Answer #1

   //list of header files

#include<stdio.h> //contains printf,scanf etc

#include<conio.h> //contains delay(),getch(),gotoxy(),etc.

#include <stdlib.h>    // contains exit();

#include<string.h> //contains strcmp(),strcpy(),strlen(),etc

#include<ctype.h> //contains toupper(), tolower(),etc

#include<dos.h> //contains _dos_getdate

#include<time.h>

#include<bios.h>   

struct Date

{

int mm,dd,yy;

};

struct books

{

int id;

char stname[20];

char name[20];

char Author[20];

int quantity;

float Price;

int count;

struct Date issued;

struct Date duedate;

};

main()

{

clrscr();

int p,c=0;

while(another=='y')

{

printf("Enter Book ID:");

scanf("%d",&p);

checkid(int t);

if(checkid(t) == 0)

{

printf("\aThe book id already exists\a");

ask current date(int);

if(ask current date(valid date) == 0)

{

printf("\a date is valid\a");

checkcurentpaseed();

}

else

printf("\a date is not valid\a");

returnfunc()

else

printf("\a no such book exits\a");

check currentdate();

int checkid(int t) //check whether the book is exist in library or not

{

rewind(fp);

while(fread(&a,sizeof(a),1,fp)==1)

if(a.id==t)

return 0; //returns 0 if book exits

return 1; //return 1 if it not

}

int t(void) //for time

{

time_t t;

time(&t);

printf("Date and time:%s\n",ctime(&t));

return 0 ;

}

ask current date(int valid date);

int dd, mm, yy; /* given date */

int valid date; /* flag to indicate date validity */

clrscr();

printf("Enter date as dd/mm/yyyy: ");

scanf("%d/%d/%d", &dd, &mm, &yy);

/* determine validity of given date */

valid date= 0;

if (yy != 0) /* check year */

{

if (mm >= 1 && mm <= 12) /* check month */

{

/* determine number of days in given month */

int mdays;

if (mm == 2)

mdays = (yy % 4 == 0 && yy % 100 != 0 || yy % 400 == 0) ? 29 : 28;

else if (mm == 4 || mm == 6 || mm == 9 || mm == 11)

mdays = 30;

else mdays = 31;

if (dd >= 1 && dd <= mdays)

valid date= 1;

}

}

}

checkcurentpaseed()

{

struct dosdate_t d; //for current date

   _dos_getdate(&d);

   a.issued.dd=d.day;

     a.issued.mm=d.month;

   a.issued.yy=d.year;

   

   printf("Issued date=%d-%d-%d",a.issued.dd,a.issued.mm,a.issued.yy);

  

   printf("The BOOK of ID %d is issued",a.id);

   a.duedate.dd=a.issued.dd+RETURNTIME; //for return date

     a.duedate.mm=a.issued.mm;

   a.duedate.yy=a.issued.yy;

   if(a.duedate.dd>30)

   {

a.duedate.mm+=a.duedate.dd/30;

a.duedate.dd-=30;

   }

   if(a.duedate.mm>12)

   {

a.duedate.yy+=a.duedate.mm/12;

a.duedate.mm-=12;

   }

   if(a.duedate.dd<a.issued.dd)

   {

printf("due date passed");

printf('the student already paid);

  

update()

printf('book**** return sucessfully);

returnfunction();

}

if(days>=15)

printf('the fine is:%d',days*1)

void returnfunction(void)

{

printf( "Selections: " );

scanf( "%d", &choice);

switch ( choice ) {

case 't': /* Note the colon, not a semicolon */

printf('tryagain')

break;

case 'b':

printf('back');

break;

  

default:

printf( "Bad choice, quitting!\n" );

break;

}   

}

void update(void) //edit information about book

{

clrscr();

int c=0;

int d,e;

printf("****update Books Section****");

char another='y';

while(another=='y')

{

clrscr();

printf("Enter Book Id to be edited:");

scanf("%d",&d);

fp=fopen("mylaibrary.txt","rb+");

while(fread(&a,sizeof(a),1,fp)==1)

{

if(checkid(d)==0)

{

printf("The book is availble");

printf("The Book ID:%d",a.id);

printf("Enter new name:");scanf("%s",a.name);

printf("Enter new Author:");scanf("%s",a.Author);

printf("Enter new quantity:");scanf("%d",&a.quantity);

printf("Enter new price:");scanf("%f",&a.Price);

printf("Enter new rackno:");scanf("%d",&a.rackno);

printf("The record is modified");

fseek(fp,ftell(fp)-sizeof(a),0);

fwrite(&a,sizeof(a),1,fp);

fclose(fp);

c=1;

}

if(c==0)

{

printf("No record found");

}

}

printf("Modify another Record?(Y/N)");

fflush(stdin);

another=getch() ;

}

returnfunction();

}

Add a comment
Know the answer?
Add Answer to:
// C programming Create a system managing a mini library system. Every book corresponds to a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Subject: Java Program You are writing a simple library checkout system to be used by a...

    Subject: Java Program You are writing a simple library checkout system to be used by a librarian. You will need the following classes: Patron - A patron has a first and last name, can borrow a book, return a book, and keeps track of the books they currently have checked out (an array or ArrayList of books). The first and last names can be updated and retrieved. However, a patron can only have up to 3 books checked out at...

  • The CIS Department at Tiny College maintains the Free Access to Current Technology (FACT) library of...

    The CIS Department at Tiny College maintains the Free Access to Current Technology (FACT) library of e- books. FACT is a collection of current technology e-books for use by faculty and students. Agreements with the publishers allow patrons to electronically check out a book, which gives them exclusive access to the book online through the FACT website, but only one patron at a time can have access to a book. A book must have at least one author but can...

  • You need to program a simple book library system. There are three java classes Book.java   //...

    You need to program a simple book library system. There are three java classes Book.java   // book object class Library.java   //library class A2.java //for testing The Book.java class represents book objects which contain the following fields title: a string which represents the book title. author: a string to hold the book author name year: book publication year isbn: a string of 10 numeric numbers. The book class will have also 3 constructors. -The default no argument constructor - A constructor...

  • Programming Assignment This is a database course using Open Office Database. Assume that you have been...

    Programming Assignment This is a database course using Open Office Database. Assume that you have been given the task of creating a system for a library to keep track of their books, the borrowers of the books, and the books that are currently lent out. Your first step will be to create the relations necessary for this system. Book will need information such as a unique identifier for each book, title, author, ISBN number, date of publication, cost. Borrower will...

  • Design an ER diagram for a library management system. The library manages books, members, and books...

    Design an ER diagram for a library management system. The library manages books, members, and books borrowed by members.  The library has several branches around the city. Each branch has a name and address and is identified by a branch ID.  Each book in the system is identified by a unique ISBN along with its title, author(s), and publisher.  A publisher is identified by its name, address, and phone. Note that publishers may be based anywhere around...

  • Design an ER diagram for a library management system. The library manages books, members, and books...

    Design an ER diagram for a library management system. The library manages books, members, and books borrowed by members.  The library has several branches around the city. Each branch has a name and address and is identified by a branch ID.  Each book in the system is identified by a unique ISBN along with its title, author(s), and publisher.  A publisher is identified by its name, address, and phone. Note that publishers may be based anywhere around...

  • IN C++ My project will be a library management system. It will have seven functions. It...

    IN C++ My project will be a library management system. It will have seven functions. It HAS to contain: classes, structures, pointers and inheritance. fix code according to below 1. Add a new book allows the user to enter in book name and book code Book code has to be in # “Invalid book code” “book name has been added to library” book code will be used to borrow books 2. Add a new user must use first user must...

  • please Code in c++ Create a new Library class. You will need both a header file...

    please Code in c++ Create a new Library class. You will need both a header file and a source file for this class. The class will contain two data members: an array of Book objects the current number of books in the array Since the book array is moving from the main.cc file, you will also move the constant array size definition (MAX_ARR_SIZE) into the Library header file. Write the following functions for the Library class: a constructor that initializes...

  • This assignment consists of a series of SQL questions. For each question, you will need to...

    This assignment consists of a series of SQL questions. For each question, you will need to include: • SQL query. • An explanation of the query. Please include explanations as a comment AFTER your query, e.g., enclosed within a /* comments block */ ). See the first example in the SQL tutorial for a comment. You don’t need to explain straightforward code in comments. Only the parts that are interesting or different, so that we understand what you did. Question-1...

  • In this project, you will construct an Object-Oriented framework for a library system. The library must...

    In this project, you will construct an Object-Oriented framework for a library system. The library must have books, and it must have patrons. The patrons can check books out and check them back in. Patrons can have at most 3 books checked out at any given time, and can only check out at most one copy of a given book. Books are due to be checked back in by the fourth day after checking them out. For every 5 days...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT