Homework 4: Functions
Wednesday, February 22, 2012[Up] [Previous Homework] [Next Homework]
Complete the following:
- Create a new file called hw04.c
- Create a program that contains the following functions:
- A function called "calc_grade" that
- Accepts four doubles representing the average of classwork for a student, the average of homework for a student, the average of quizzes for a student, and the final test grade for a student (all values are between 0 and 100)
- Calculates the student's class grade if classwork is worth 16% of their class grade, homework is worth 24% of their class grade, quizzes are worth 30% of their class grade, and the final is worth 30% of their grade
- A function called "display_grade" that
- Accepts a single double
- Prints "CLASS GRADE IS: " followed by the class grade for the student
- A function called "calc_grade" that
- Write main so that it will call whichever functions are necessary to:
- Ask the user for the classwork, homework, quiz, and final averages for a student
- Get the values from the user
- Calculate the class grade based on supplied input
- Display the class grade based on supplied input
- Get input and calculate the class grades for three students without running the program multiple times
- It is recommended you write your own function(s) to minimize writing the same code multiple times
- Example of expected output:
linux3[1]% ./hw04 Please input classwork total (0-100): 50 Please input homework total (0-100): 50 Please input quiz total (0-100): 80 Please input final exam total (0-100): 90 CLASS GRADE IS: 71.000000 Please input classwork total (0-100): 85 Please input homework total (0-100): 85 Please input quiz total (0-100): 90 Please input final exam total (0-100): 95 CLASS GRADE IS: 89.500000 Please input classwork total (0-100): 95 Please input homework total (0-100): 100 Please input quiz total (0-100): 80 Please input final exam total (0-100): 92 CLASS GRADE IS: 90.800000 linux3[2]%
- Create a script of you compiling and then running your program once (running multiple times is not required)
- Once you are done, use submit to submit two files, hw04.c and typescript
linux3[1]% submit cs104_sheets hw04 hw04.c typescript