Question
Program in C: Write a program called grade_need.c that calculates the minimum percent needed on the final to achieve the desired grade. If the desired
Program in C:
Write a program called grade_need.c that calculates the minimum percent needed on the final to achieve the desired grade. If the desired grade cannot be achieved because the person cannot score low or high enough on the final to get the desired grade, your program should tell them so.
Grade | Minimum Percent Needed |
A | 90% |
B | 80% |
C | 70% |
D | 60% |
F | 0% |
Requirements
- Your program should be able to accept both lowercase and uppercase letters for the letter grade desired
- The program must compile with both -Wall and -Werror options enabled
- Submit only the files requested
- Use doubles to store real numbers
- Print all doubles to 2 decimal points unless stated otherwise
Restrictions
- No global variables may be used
- Your main function may only declare variables and call other functions
Assumptions
- Input is NOT guaranteed to be valid
- Some examples of improper input are
- Incorrectly formatted input
- Incorrect letter grades desired
- If invalid input is received, your program should report it and terminate
- You'll find the exit function in stdlib.h for doing this. Make sure to only use 0 with exit and no other value.
- Wait until we cover how to handle invalid input in class before dealing with this part of the problem
- Some examples of improper input are
Examples
Example 1
Enter the grade you want in the class: B Enter your current percent in the class: 75 Enter the weight of the final: 20 You need a grade of at least 100.00% on the final to get a B in the class.
Example 2
Enter the grade you want in the class: b Enter your current percent in the class: 75 Enter the weight of the final: 25 You need a grade of at least 95.00% on the final to get a b in the class.
Example 3
Enter the grade you want in the class: A Enter your current percent in the class: 85 Enter the weight of the final: 20 You cannot get a A in the class because you would need to score at least 110.00% on the final.
Example 4
Enter the grade you want in the class: F Enter your current percent in the class: 90 Enter the weight of the final: 10 You cannot score low enough on the final to get a F in the class.
Example 5
Enter the grade you want in the class: H Unknown Grade Received: H. Ending program.
Example 6
Enter the grade you want in the class: C Enter your current percent in the class: bob Invalid formatting. Ending program.
Example 7
Enter the grade you want in the class: A Enter your current percent in the class: 87 Enter the weight of the final: !75 Invalid formatting. Ending program.
Example 8
Enter the grade you want in the class: B Enter your current percent in the class: 12G Invalid formatting. Ending program.
Example 9
Enter the grade you want in the class: B Enter your current percent in the class: -35 The number you last entered should have been positive. Ending program.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started