Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Design a student grade calculator program. Get the user's first name and store it to a char array Declare a character array to hold at

Design a student grade calculator program.

  1. Get the user's first name and store it to a char array
    • Declare a character array to hold at least 20 characters.
    • Ask for the user's firstname, and store the name into your char array.
  2. Get 5 test scores from the user :
    • Declare an array of 5 floating point elements.
    • Use a for loop to get the user's 5 scores.
      • Assume that all scores are out of 100. You are not required to request the maximum score.
      • Assume that the user input is valid. You are not required to validate user input.
    • Your prompts should print out which test score you are asking for:
      • Example: "What is the score of test #1?" ... "What is the score of test #3?"
    • Warning: Be careful of your array indexes!
  3. Calculate the average test score:
    • Use a for loop to calculate the sum of all examinations.
    • Divide the sum by 5 to get the average and store this data in another variable.
  4. Print the summary for the user similar to:
    • "Hello Charley, based on your test scores of 80, 75, 90, 85 and 100, your average is 86.00% with letter grade of an 'B'"
    • You should re-use your previous code to calculate the grade letter from the average percentage.

Old code:

#include #include int main(void) { float max_score, user_score, percentage; char letter_grade, any_key; int points_needed; printf(" What is the max score of your exam? : "); scanf_s("%f", &max_score); if (max_score == 0) { printf(" Invalid input"); exit(0); } printf(" What was your score? : "); scanf_s("%f", &user_score); if ((user_score > max_score)) { printf(" Invalid input"); exit(0); } percentage = (user_score / max_score) * 100; if (percentage >= 90) { letter_grade = 'A'; } else if (percentage >= 80 && percentage < 90) { points_needed = 90 - (int)percentage; letter_grade = 'B'; } else if (percentage >= 70 && percentage < 80) { points_needed = 80 - (int)percentage; letter_grade = 'C'; } else if (percentage >= 60 && percentage < 70) { points_needed = 70 - (int)percentage; letter_grade = 'D'; } else { letter_grade = 'F'; } if (letter_grade == 'A') { printf(" You scored %d%% which is an A. Good job!", (int)percentage); } else if (letter_grade == 'F') { printf(" You scored %d%% which is an F. Try Again.", (int)percentage); } else { printf(" You scored %d%% which is a %c. You were %d percent away from the next grade", (int)percentage, letter_grade, points_needed); } printf(" Program finished, press any key to quit..."); scanf_s("%c", &any_key); printf(" You pressed %c to quit the program with ASCII code %d", any_key, any_key); exit(0); return 0; }

What is the output of the following code segment and why?

int main(void) { // Find the output of the following and explain it: char name[] = "Hello"; name[2] = '\0'; printf("%s ", name); return 0; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Probabilistic Databases

Authors: Dan Suciu, Dan Olteanu, Christopher Re, Christoph Koch

1st Edition

3031007514, 978-3031007514

More Books

Students also viewed these Databases questions

Question

Explain the sources of recruitment.

Answered: 1 week ago

Question

Differentiate sin(5x+2)

Answered: 1 week ago

Question

Compute the derivative f(x)=1/ax+bx

Answered: 1 week ago

Question

What is job enlargement ?

Answered: 1 week ago

Question

What does Processing of an OLAP Cube accomplish?

Answered: 1 week ago