Previous: 12.7 Exercises
Up: 12 Structures and Unions
Previous Page: 12.7 Exercises

12.8 Problems

  1. Write the function printsortedlabels() described in Section 12.3 and make the modifications to main() to read a list of address labels and print them in sorted order by last name.

  2. Define a structure with the following members:
    social security number
         id number
         name (last, first, middle)
         exam score
    Use the above structure for the data record of one student in a class of 50 students maximum. Write a menu-driven program that allows the commands: read data from an input file into an array of the above structure; print data on screen; save data into an output file; sort the data by a specified primary key using pointers to the array; quit.

  3. Modify Problem 2 to allow more than one exam up to a maximum of 5 exams. Use an array of exam scores in the structure. Assume that the first three lines of the input file include course title and headings. The actual data starts with the fourth line.

  4. Modify Problem 3 to compute and store a weighted average of the exam scores for each student. Weighted average should be a member of the structure. Also allow for computation of an average of any one or all the exams.

  5. Modify Problem 4 to allow deleting one or more records, changing one or more records, adding one or more records.

  6. Modify Problem 5 so that it can read an input file which may or may not contain a column for the weighted average. Allow the user to output the data but specify which data fields are not to be output to a new file.

  7. Modify the above program to include scores for a number of projects up to a maximum of 15. Weighted average must now include exam as well as project scores. Allow a structure member for a letter grade.

  8. Modify the above program so it allows the user to perform the following functions: form a class grade list for a new class; enter grades for a project or an exam; change grades for a project or an exam; add or delete a student from a class list; calculate the average for a project or an exam; calculate the weighted average for each student over the projects and the exams; sort the data by a primary key, e.g. weighted average, exam2, proj3, etc.; sort the data by a primary key and a secondary key, i.e. if two records have the same primary key, then sort those records by a secondary key; plot a distribution of the weighted average grades.

  9. Write a program that keeps a membership list for a private club. The data fields required are:
    name
         spouse name if any
         address, business, residence
         telephone, business, residence
         hobby interests
         membership date
         dues outstanding
         other charges outstanding
    The club has a limit of 100 members. Write a program that allows the club manager to: maintain the club list and update it; send out a mailing list to all members with all data about the club members, except for financial data; send out reminders to members about the charges outstanding; post new charges and dues at regular intervals; post paid amounts upon receipt.

  10. Assume that the above club maintains a library of at most 500 books. Data for each book consists of:
    book number
         title
         author
         co-authors
         publisher
         date published
         subject
         keywords
         check out data:
              name, address, phone
              date checked out
              data returned
              charges, if any
    Write a program to maintain the library including: search the library by book number, author, title, subject, keywords; add new books, remove outdated books (all books older than 5 years); check out books; late charges at $0.25 per day if a book is out by more than a month; write data to a file for books overdue and charges.

  11. Write a macro processor assuming that the macros do not have arguments. Use a structure to keep a macro identifier and its replacement string. Read an input file which may have macros, and create an output file with macros replaced by replacement strings.

  12. Write a macro processor. Assume that macros may have arguments. Use structures to keep data about a macro.

  13. Use a structure to represent a rational number. Write functions for rational number arithmetic. Write a simple calculator program for rational numbers.



Previous: 12.7 Exercises
Up: 12 Structures and Unions
Previous Page: 12.7 Exercises

tep@wiliki.eng.hawaii.edu
Sat Sep 3 07:12:43 HST 1994