Question: Write a python program . A library maintains its book information (stock) in a text file. An application needs to be developed which will read

Write a python program .

A library maintains its book information (stock) in a text file. An application needs to be developed which will read the text file and display all the books available for borrowing. Then with each transaction (borrowing) a note should be generated for the particular borrower and should be written into a file. The stock of the books should also be updated after each transaction. For example, if the library had 10 books of specific title, then if one of those books is borrowed then the number should change to 9. In the case of returning a book, a note should again be generated for the person returning the book. The stock should also be updated i.e. the quantity of the book returned should be increased by 1.

A sample format of the text file containing the information about the books is as follows:

Harry Potter,JK Rowling,30,$2

Start With Why,Simon Sinek,10,$1.5

Programming With Python,John Smith,20,$1.5

*1st column contains the name of the book, 2nd column contains the name of the author, 3rd column contains the quantity available, 4th column contains the price for borrowing the book (for duration of 10 days)

**You can use your own format and add other information too

A note should be generated for each transaction. When a person borrows a book a note should be generated which must contain the name of the borrower, the name of the book borrowed, the date and time of such issue and the total amount to be paid for the borrowing. If a person decides to borrow multiple books then all the borrowed books should be written to the note and the amount should be added up for all the borrowed books.

When a person returns a book to the library, a note should be generated and written to the file again. The note should contain the name of the borrower, name of the book, date and time of the return. The lending duration should be set to 10 days, and if a person is late in returning the book, a fine should be applied on a daily basis which should also be present in the generated file.

* The format of the borrowing and returning notes is up to you. But each file should have a unique name.

4

2. Algorithm

An algorithm should be developed for the application where everything the program does should be taken into account. The algorithm should be described in steps, pseudocode and flowcharts should also be included.

3. DataStructures

The programming should be done using data structures and operations in Python for input/output, character and string processing, data storage.

It can use any primitive or complex data structures which might be necessary for holding the data (lists, tuples, strings, dictionaries, etc.)

The choice of data structures must be specified in the report. 4. Program

The program must work in a loop, displaying the available books and waiting for the administrator to enter the details. The program should not close unless the administrator decides to do so.

The program must check the input data, displaying error messages whenever unwanted data is entered, for example if some string value is entered where a numerical value is expected.

The program must be implemented in a modular way with separate functions for the different operations such as user input, reading files, generating borrowing/returning notes, etc.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!