A Program That Reads In A List Of Classes From A text File
Program 2 Introduction to C
CSCI 112, Fall 2018
Objectives • Practice reading from and writing to files. • Practice using data structures. • Learn to work in a team
Description: Using the same team you had for program 1, create a program that reads in a list of CSCI classes from a file (must use file pointers). Store the list in a data structure. Allow the user (a student) to have the following options:
1) Print all classes by CSCI number (include all information) in order of CSCI number.
2) Print all classes available on MWF or available on TR in order of times. 3) Print the class available at a specific time (test this with MWF 0900 and TR 1100) 4) Print classes available to freshman, sophomore, junior or senior (corresponds to
last number on each line in the input file) in order of CSCI number. This means you have to convert back and forth between the strings (freshman, …) and the numbers (1,2, …).
5) Quit
All output will be written to a file (must use file pointers). Requirements: You must use the input file in /home/csci112 called classes.txt to input the data. You must provide the options to the user on the screen as shown above in description. You must write all information asked for by the user to an output file. This means that you will need to interact with the user (asking for options) by printing to STDOUT but print all the responses to the queries to a file. To print class information, print in the following order: Title, Class number (ex: CSCI112), available for (freshman, soph…), day, time. You must loop on user queries until the user selects the quit option.
You must exit with a failure if any error is found in user input. Place each function or group of functions in a separate file (.c) and have a Makefile that compiles all your code together to make the executable. A group of functions means that you might have all your print functions in one file, but you would not have the query function in the same file as the print functions. Submission
• Lab Days: 11/9, 11/16, 11/30 • Due Date: 11/30 at midnight
• One person from the group will submit the code and screenshot. Both partners’ names must be in the comments in the code for the main function. queryd
• Learn how to change permissions on your directory so that each of you can copy from the other’s directory.
• Once you get the code and Makefile together on your PC, zip it together and place the zip file on brightspace. Also put the output file and the screen shot of the results on BrightSpace. Submit your work on or before the deadline as late work will receive a 50% penalty. Labs submitted more than 24 hours late will not be accepted.
Grading Points
• 2 – good style/coding practices used: comments included in code, white pspace between functions, code indented
• 6 – runs (that means that if it doesn’t run, submit it anyway) • 8 – followed instructions (ex: 2 functions, etc) • 2 – provided screenshot of compile and runs and source file (as .c file) • 2 – worked with a partner