0% found this document useful (0 votes)
3 views

14 Homework - C File Processing Part 1

The document outlines an assignment for CIS 236, requiring students to write a C program that manages movie information using structures and file handling. It specifies the use of functions to read from and display movie data, with extra credit opportunities for additional features like writing to a file and handling genres. Students must adhere to coding best practices and submit their source code file by the due date.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

14 Homework - C File Processing Part 1

The document outlines an assignment for CIS 236, requiring students to write a C program that manages movie information using structures and file handling. It specifies the use of functions to read from and display movie data, with extra credit opportunities for additional features like writing to a file and handling genres. Students must adhere to coding best practices and submit their source code file by the due date.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

CIS 236 – Programming in C

14 Homework – Files, Part 1


25 points
Description
Write a program that stores information about movies, using an array of structures and a text file.
This program modifies the Week 13 Homework program. If you have not finished that program, go
back and finish it first.
You must use functions as described in the requirements below.
Extra credit is available for this assignment.
Learning Objectives
 Use an array of programmer-defined structures
 Use a repetition control structure
 Use a function using an output argument to get data from the user
 Use a function with an array argument to display output to the screen
 Read from a text file using fscanf
 Read from a text file without using fscanf (extra credit)
 Write to a text file (extra credit)
 Use enumerated data types (extra credit)

Requirements
Instead of getting the movie data from the user, read the data from a plain text file.
1. Your code must use two functions (in addition to main) as described below.
2. The structure requirements are the same as Homework 08.
3. Your code must use a symbolic constant for the size of the array.
Requirements for Function 1 (Updated from Homework 13)
Purpose: This function opens and reads a plain text containing movie information and stores the
information in the appropriate position in the array. Then it closes the file.
Name: Give this function a meaningful name
Parameters: array of movie structures
Return value: None
Algorithm: 1. Open the file appropriately. Be sure to verify that the file opened successfully.
2. Then, within a loop that reads until the end of the file, use fscanf to read the movie
titles and numbers of downloads from a plain text file with the following format:
TitleOfMovie NumberOfDownloads
3. Note that the title of the movie will NOT have any spaces in it. Always set the last
element in the string to the null character, regardless of the length, although no
message is required.
4. All information should be stored directly into the appropriate location in the output
parameter.
5. Continue to read the movie information until the end of the file (EOF). DO not use
a counter-controlled loop for this!
6. After the loop, close the file.

Requirements for Function 2 (Same as Hmwk 13, unless you added the extra credit)
Purpose: This function displays the contents of the movie array.
Name: Give this function a meaningful name

Parameter: array of movie structures

Return value: None


Algorithm: Use a counter-controlled loop to display the contents of the array in a neatly formatted
list, per the sample run.

Requirements for main (Updated from Homework 13):


1. Create an array of movie structures of size 5. You can assume that there will not be more than 5
movies listed in the input file.
2. Call function 1 and pass the array of movie structures.
3. Call function 2 and pass the array of movie structures.
4. Extra credit 1 – call function 3.
Function 3 – Extra Credit 1 – Max 5 Points – Write Movie Information to Output File
Purpose: Create another function that stores the contents of the movie array in a text file.
Name: Give this function a meaningful name
Parameters: array of movie structures
Return value: None
Algorithm: 1. Create a text file. DO NOT USE THE SAME FILE NAME AS YOUR INPUT FILE.
2. Use a counter-controlled loop to write the contents of the array to this file, using the
same file format as shown in the requirements for the function 1.
3. Be sure to only print existing data. Do not print empty structures.
4. Then close the file.
Extra Credit 2 – Max 5 or 10 Points – Handle Genre in the Movie Information
If you implemented the genre in Week 13, you can also handle the genre in this assignment for a max
of 5 extra credit points.
If you did not implement the genre in Week 13, you can also handle the genre in this assignment for a
max of 10 extra credit points.
Refer to the instructions for Week 13 regarding how to include the genre in the structure, and how to
handle it in function 2.
In this version of the input file, the genre is stored as a number after the number of downloads:
TitleOfMovie NumberOfDownloads Genre
Update function 1 to handle this additional item. You can assume the genre value will be a valid genre.

Sample Run – Required


Title Downloads
===== =========
Oppenheimer 1000000
AquamanandtheLostKing 3000000
TheLittleMermaid 3000000
TheMarvels 17340
Barbie 25000000
Sample Run – Extra Credit 2
Title Downloads Genre
===== ========= =====
Oppenheimer 10000000 Drama
AquamanandtheLostKing 3000000 Action
TheLittleMermaid 3000000 Animation
TheMarvels 17340 Superhero
Barbie 25000000 Fantasy

Requirements for Full Credit on This Project


1) COMPLETE AND ACCURATE
Your program must include all required components and techniques as noted above. It must
compile, execute, and give accurate output.
2) FOLLOW ALL REQUIREMENTS ACCORDING TO THE INSTRUCTIONS.
Follow the instructions as written for completing this project, even if you [think you] know a
“better” way to do something.
3) DO NOT USE TECHNIQUES WE HAVE NOT COVERED IN CLASS.
4) COMMENTS
There must be a comment at the top of your source code file that includes your name, the
assignment number, and a short description of the program. Additionally, every function, control
structure, executable statement and variable declaration must be described with a comment. This
does not include whitespace or lines that contain only curly braces.

5) BEST PRACTICES
Follow best practices in C programming. These include, but are not limited to, the following:
 Appropriate use of white space and alignment
 Meaningful variable names and appropriate naming conventions
Points will be deducted for sloppy code that is hard to read, even if it works, so pay attention to
these details.
6) SUBMIT ALL FILES BEFORE THE DUE DATE
See the due date for this assignment on the course calendar in Canvas and review the submission
requirements below.
7) ALL SUBMISSIONS MUST BE YOUR OWN WORK
Review the syllabus regarding plagiarism and the Joliet Junior College Academic Honor Code.
BY SUBMITTING ANY ASSIGNMENT, YOU ARE STATING THAT YOUR SUBMISSION IS YOUR OWN WORK
AND IS NOT PLAGIARIZED IN ANY FORM.
Submission
Submit your C source code file with the .c file extension to the drop box.
I will not accept links to online storage. You must submit the actual file. Do not submit an entire IDE
project.

Remember – do not ask time-sensitive questions as a comment in the drop


box. If you need help, contact me directly before the assignment is due.

You might also like