This program will consist of 3 files: main.c, scores.c,scores.h main.c will contain your main function,scores.c will contain the functions describedbelow and any additional helper functions that you may need,scores.h will contain prototypes for the functionsin scores.c. The main.c file should contain the line #include"scores.h".
In the file scores.c, create a function doublegetScore(), this function should prompt the user fora test score between 0 and 100, it should read a value fromkeyboard and validate it. If the score is invalid the user shouldsee an error message and then asked to input the score again. Oncea valid score is obtained the function should return the value.
The main function in main.c should call thegetScore() function three times and storethe results into three different variables.
After all values are read in, the main function should callanother function from scores.c called doublegetAdjustedAverage(double, double, double) which takethe three doubles as input parameters and returns the average ofthe highest and lowest values. In other words if the values 50, 70,and 80 are given the function should return the value 65 which is(50+80)/2.
To determine which value to exclude, create 2 more functions inscores.c called double highest(double, double, double)and double lowest(double, double, double) whichreturn the highest and lowest of the 3 values passed to itrespectively.
• main.c
o Includes scores.h header
o Functions: main()
o Calls the functions inscores.c to get scores and average, displays the results.
• scores.c
o Functions: getScore(),getAdjustedAverage(), highest(), lowest()
• scores.h
o Prototypes for functions inscores.c
Example:
An example of what the output might look like is below (userinput is in red):
Enter a grade between 1 and 100? 87.5
Enter a grade between 1 and 100? 148.7
Invalid value, enter a value between 0 and 100: 48.7
Enter a grade between 1 and 100? 91.2
The average of 48.7 and 91.2 is: 69.95
This program will consist of 3 files: main.c, scores.c, scores.h main.c will contain your main function, scores.c will c
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am