-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfinal_grade.c
More file actions
31 lines (26 loc) · 965 Bytes
/
final_grade.c
File metadata and controls
31 lines (26 loc) · 965 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/*
This program asks for details about your current grade in class
and displays the percent you need to get atleast to achieve the final grade of your choice.
*Assuming all input is valid.
*/
#include <stdio.h>
int main(void) {
char grade;
float percentToGet, currentPercent, finalweight, finalgrade;
printf("Enter the grade you want in class: ");
scanf("%s", &grade);
printf("Enter the percent you need to get that grade: ");
scanf("%f", &percentToGet);
printf("Enter your current percent in the class: ");
scanf("%f", ¤tPercent);
printf("Enter the weight of the final: ");
scanf("%f", &finalweight);
finalgrade = (percentToGet - ((100 - finalweight) / 100) * currentPercent) * (100 / finalweight);
printf("You need to get atleast: ");
printf("%.2f", finalgrade);
printf("%%");
printf(" to get a ");
printf("%c", grade);
printf(" in the class.\n\n");
return 0;
}