Westonci.ca is your go-to source for answers, with a community ready to provide accurate and timely information. Our platform provides a seamless experience for finding reliable answers from a network of experienced professionals. Discover in-depth answers to your questions from a wide network of professionals on our user-friendly Q&A platform.
Sagot :
Answer:
The program in C is as follows:
#include <stdio.h>
char turn_to_letter(double score){
char lettergrade = 'A';
if(score>=80){ lettergrade = 'A'; }
else if(score>=70){ lettergrade = 'B'; }
else if(score>=60){ lettergrade = 'C'; }
else if(score>=50){ lettergrade = 'D'; }
else{lettergrade = 'F';}
return lettergrade;
}
int main(){
int midterm, final;
double score;
printf("Midterm: "); scanf("%d", &midterm);
printf("Final: "); scanf("%d", &final);
score = 0.4 * midterm + 0.6 * final;
printf("Score: %lf\n", score);
printf("Letter Grade: %c",turn_to_letter(score));
return 0;
}
Explanation:
The function begins here
char turn_to_letter(double score){
This initializes lettergrade to A
char lettergrade = 'A';
For scores above or equal to 80, grade is A
if(score>=80){ lettergrade = 'A'; }
For scores above or equal to 70, grade is B
else if(score>=70){ lettergrade = 'B'; }
For scores above or equal to 60, grade is C
else if(score>=60){ lettergrade = 'C'; }
For scores above or equal to 50, grade is D
else if(score>=50){ lettergrade = 'D'; }
Grade is F for other scores
else{lettergrade = 'F';}
This returns the letter grade
return lettergrade;
}
The main begins here
int main(){
This declares the midterm and final scores as integer
int midterm, final;
This declares the total score as double
double score;
These get input for midterm score
printf("Midterm: "); scanf("%d", &midterm);
These get input for final score
printf("Final: "); scanf("%d", &final);
This calculates the total score
score = 0.4 * midterm + 0.6 * final;
This prints the calculated total score
printf("Score: %lf\n", score);
This calls the turn_to_letter function and prints the returned letter grade
printf("Letter Grade: %c",turn_to_letter(score));
return 0;
}
We hope you found this helpful. Feel free to come back anytime for more accurate answers and updated information. We appreciate your time. Please revisit us for more reliable answers to any questions you may have. Thank you for using Westonci.ca. Come back for more in-depth answers to all your queries.