hi ther,

I need a help in my C assignment, which is to be submitted tommorrow. I am attaching the question along with this. I am in a desperate situation, as i m very new to C. I m looking forward to hear from u ASAP...V have to run this program on unix platform only, and no C++ COMMANDS shud b used....thnx a lot


here is the question(it can b viewed in the attachment also):


Implement a menu driven library catalogue system that allows users to perform various catalogue maintenance tasks. You are only allowed to use the C programming language. You are not allowed to use C++.

Please do not use global variables. Up to 50% of marks will be lost for assignments that use global variables.

Please use dynamic memory allocation to store student record information. Up to 50% of marks will be lost for assignments that do not use dynamic memory allocation to store student record information.

Please do functional decomposition. Up to 50% of marks will be lost for students who try to write the entire program in one main function or something similar. There should be at least 5 functions for the assignment. One function for each task 2 to 4. Two functions for task 5. More functions than 5 is highly recommended. The aim of this rule is to teach you how to pass pointer arguments into functions.

The assignment has been broken up into 5 tasks.

Task 1 [10 marks code correctness]

The program should be menu driven. The user should be presented with the following menu:

1. Load catalogue from file
2. Delete book from catalogue
3. Save catalogue to file
4. Sort and display catalogue
5. Quit

After selecting one of the above options the corresponding task should be performed. After completing the selected task, the menu should be displayed again for the user to choose from again.


Task 2 [20 marks code correctness]

Implement the load catalogue from file menu option. After selecting this option the user should be asked to enter the name of a file to be loaded. The file should then be loaded into a run-time(dynamically) allocated data structure. You should not use compile-time (static) memory allocation. You can assume the file will have the following format.


[Number of books]
[Title of book]
[Author first name], [Author surname]
[Year of publication]
[Replacement cost]


[Title of book]
[Author first name], [Author surname]
[Year of publication]
[Replacement cost]


The … stands for intermediate catalogue entries.

Here is an explanation of the above fields:

[Number of books] - This is the number of book entries stored in the file

[Title of book] – A string specifying the title of the book, the string may contain spaces.

[Author First name], [Author Surname] – Two strings which do not contain spaces but
are separated by a comma followed by a space.

[Year of publication] - A number specifying the year that the book was published

[Replacement cost] - Cost of replacing a book, it may contain a decimal point.


Below is an example of a catalogue file that contains 2 books:

2
C for beginners
Peter, Kernighan
1999
102.5
XML data Management
Amit, Chandhri
2005
122.3






Task 3 [15 marks code correctness]

Implement the delete book from catalogue menu option. After selecting this option the user should be asked to specify the book to be deleted using the following sub-menu:

1. Specify book title
2. Specify author first name
3. Specify author last name

After choosing one of the above sub-menu options, the user should be asked to type in a string to be used for finding the book to be deleted. Note the string has to completely match the book attribute. Partial match is not considered a match.



In the following example the user strings does not match the corresponding books:

User types in for book title: Cforbeginners
Actual book title: C for beginners

User types in for author first name: peters
Actual book author first name: peter

User types in for author surname: peter
Actual book author surname: peterson

The search should be case insensitive. Therefore the following does match:

User types in for author first name: peter
Actual book author first name: peTer

User types in for book title: c for beginners
Actual book title: C For Beginners


If more than one matching book is found then all matching books are deleted. The program needs to free up memory that is no longer needed as a result of the deletion.







Task 4 [10 marks code correctness]

Implement the save catalogue to file menu option. After selecting this option the user should be asked to specify the name of the save file. All the book catalogue data should be stored onto the specified file in the same format as the file loaded in Task 2.


Task 5 [20 marks code correctness]

Implement the sort and display catalogue menu option. Once this option is selected the following sub-menu is displayed:

1. Sort books by title
2. Sort books by surname
3. Sort books by replacement cost
4. Sort books by year of publication

To get full marks for this task you should design your sorting algorithm so that it uses function pointers to allow the same algorithm implementation to be used to sort for all 4 different attributes.

After the above choice is made the books are sorted in ascending order and all the books attributes are displayed as follows:

Number of books in catalogue = [number of books]
---------------------------------------------------------------
Title: [title of book]
Author: [first name of author] [surname of author]
Year of publication: [year of publication]
Replacement cost: $[cost of replacement]
---------------------------------------------------------------
....
....
---------------------------------------------------------------
Title: [title of book]
Author: [first name of author] [surname of author]
Year of publication: [year of publication]
Replacement cost: $[cost of replacement]
---------------------------------------------------------------

Note: [title of book] [first name of author] [surname of author] [year of publication]
[cost of replacement] have the same meaning as those for task 2.

Here is an example output:

Number of books in catalogue = 2
---------------------------------------------------------------
Title: C for beginners
Author: Peter Smith
Year of publication: 1999
Replacement cost: $102.50
---------------------------------------------------------------
Title: Java programmers hand book
Author: John Edwards
Year of publication: 2003
Replacement cost: $105.2
---------------------------------------------------------------