Build a function called getAvg() that returns the average of three numbers Takes
ID: 3758254 • Letter: B
Question
Build a function called getAvg()that returns the average of three numbers
Takes 3 floating-point numbers
Returns the average of three numbers.
Do not use a global variable, and do not use printf/scanf inside this function
Assignment
1) Use all applicable functions from previous assignment if possible, but modify the getAvg() function.
The parameters of this function should be pointer to an array, and the size of the array.
Returns the average of the array.
2) Build a function called getExamScoreFromUser()
Ask the user to enter the exam score
scanf() into a local variable
return the number the user entered.
3) Build and present a menu to a user like the following and enclose it into a loop that ends when the Quit option is chosen.
Enter user name.
Enter exam scores.
Display average exam scores.
Display summary.
Quit
4) For choice 1, scanf a string, and store it to a username char array.
5) For choice 2, do the following :Ask the user how many exams there are. Only ask the user this number of exam scores to enter
Hint: Declare an integer array of 100, and some array members will be left un-used which is okay
If the user wants to enter more than the array size we declared, display an error, and have the user re-entry the exam count.
Use a for loop in combination with getExamScoreFromUser() to get your exam score.
Hint: You can use this inside your for loop: scores_array[i] = getExamScoreFromUser()
6) For choice 3, do the following :
If the user has already entered exam scores, use the getAvg() function to get the average of the exam scores.
If the user has not yet entered exam scores, display an error message similar to: "Please use the menu to enter exam scores first"
7) For choice 4, if the user has not yet entered their name and exam scores, display an error message. Otherwise display the average, the letter grade of the average, and the user's name.Example: "Hello Preet, your exam scores were 80, 80, 90, 90, 100, 100. Your average is 90.0 with letter grade: A"
Hint: You will need to print "Hello Preet, your exam scores were " first, and then use for loop to print the exam scores, followed by ". Your average is 90.0 with letter grade: A"
Use the getAvg() and getGradeLetter()where possible.
8) When the Quit option is chosen, end the primary loop that contains the menu.
9) Insert a line with your favorite character before printing the menu.
Explanation / Answer
Assinment 3,4,5:
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.