Answer to Question #299985 in C for Justin

Question #299985

Write a C program based on the Output below:


Note. You can use Conditional Statement and Switch- case Statement


Sample put 1:


Enter Students name: Glearn Noynay


Please select your sexual category by typing Male or Female: Male


Welcome! Mr. Glearn Noynay



Enter your grade in Ethics: 90


Enter your grade in Mathematics: 93.1


Enter your grade in Science: 75.5


Enter your grade in P.E: 83


Enter your grade in Filipino: 89.3



.....analytic rating...... ...Numeric Grade..


A+ 90-100


A 80-89


P 75-79


F Below 75


Hi,Mr.Glearn Noynay,your average grade is 86.18 with an analytic rating of A


Congratulations! You have passed this Semester



1
Expert's answer
2022-02-19T16:56:14-0500
#include <stdio.h>
#include <string.h>

int main()
{
    float sumgrade = 0;
    float grade;
    char studentName[20];
    char scategory[10];
    char* subject[5] = {"Ethics", "Mathematics", "Science", "P.E", "Filipino"};
    char rating[2];
    printf("Enter Students name:");
    scanf("%[^\n]", studentName);
    fflush(stdin);
    printf("Please select your sexual category by typing Male or Female:");
    scanf("%s", scategory);
    fflush(stdin);
    if (strcmp (scategory, "Male") == 0)
           sprintf(scategory, "Mr.");
       else if (strcmp (scategory, "Female") == 0)
           sprintf(scategory, "Ms.");
    printf("\nWelcome! %s %s \n\n", scategory, studentName);
    for (int i = 0; i < 5; i++)
    {
        printf("Enter your grade in %s:", subject[i]);
        scanf("%f", &grade);        
        sumgrade += grade;
        }
    sumgrade = sumgrade / 5;
     if (sumgrade >= 90 && sumgrade <= 100)
        sprintf(rating, "A+");
    else if (sumgrade >= 80 && sumgrade <= 89)
        sprintf(rating, "A");
    else if (sumgrade >= 75 && sumgrade <= 79)
        sprintf(rating, "P");
    else
        sprintf(rating, "F");    
       
    printf("\nHi, %s %s, your average grade is %.2f with an analytic rating of %s\n\n", scategory, studentName, sumgrade, rating);  
    printf("Congratulations! You have passed this Semester\n\n");
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS