Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In C code: Problem 1: Calculate your grade (50 points) Write a C program to calc

ID: 3699538 • Letter: I

Question

In C code:

Problem 1: Calculate your grade (50 points) Write a C program to calculate student grades in this class. Your code must use a structure named studentinfo. The structure must have the following fields (at least) » Student Name: A character array for the student's name; 100 elements is fine ·Zyante-Assignments : An integer array of 3 Zybooks entries (only 3 to reduce the number of inputs) » Homework Assignments : An integer array of 5 homework entries (only 5 to reduce the number of inputs) » In Class Participation: An integer, number of points earned for inclass participation » Midterml : An integer, points earned on exam 1 » Midterm2 : An integer, points earned on exam 2 » Final Project : An integer containing the points earned on the project » Grade Prcnt : A float showing the percentage calculated » Letter Grade : A char showing the letter grade Your C program must 1. Prompt the user to enter in the number of students in the class 2. Dynamically allocate memory for the appropriate number of students 3. Ask the user to enter information for each student: » Student's Name » Student's scores for each Zyante participation, homework assignment, in-class participation, midterm, and final project 4. Calculate grade percent, and letter grade 5. Ask the user which student's information should be displayed 6. Display the information for that particular student 7. Repeat steps 5 and 6 until the user decides to quite 8. Free any memory that was dynamically allocated

Explanation / Answer

#include <stdio.h>

#include <stdlib.h>

typedef struct Student{

char Student_Name[100];

int Zyante_Assignments[3];

int Homework_Assignments[5];

int In_Class_Participation;

int Midterm1;

int Midterm2;

int Final_Project;

float Grade_prcnt;

char Letter_Grade;

}student_info;

void Scan_Student_Info(student_info *s){

int i;

printf("Enter 3 Zybooks scores(out of 10) :");

for(i=0;i<3;i++)

scanf("%d",&s->Zyante_Assignments[i]);

printf("Enter 5 homework scores(out of 100) :");

for(i=0;i<5;i++)

scanf("%d",&s->Homework_Assignments[i]);

printf("Enter the in-class participation score (out of 100) :");

scanf("%d",&s->In_Class_Participation);

printf("Enter midterm 1 (out of 100) :");

scanf("%d",&s->Midterm1);

printf("Enter midterm 2 (out of 100) :");

scanf("%d",&s->Midterm2);

printf("Enter final project(out of 100):");

scanf("%d",&s->Final_Project);

}

void Print_Student(student_info X)

{

printf("Grade information for %s ",X.Student_Name);

printf("Zybooks Scores = [%d,%d,%d] ",X.Zyante_Assignments[0],X.Zyante_Assignments[1],X.Zyante_Assignments[2]);

printf("Homework Scores = [%d,%d,%d,%d,%d] ",X.Homework_Assignments[0],X.Homework_Assignments[1],X.Homework_Assignments[2],X.Homework_Assignments[3],X.Homework_Assignments[4]);

printf("In-class Participation Score = %d ",X.In_Class_Participation);

printf("Midterm Scores = [%d,%d] ",X.Midterm1,X.Midterm2);

printf("Final Project Score = %d ",X.Final_Project);

float zs,hs,in_part,mid1,mid2,fin_proj;//variables for Grade weights

zs=(X.Zyante_Assignments[0]+X.Zyante_Assignments[1]+X.Zyante_Assignments[2])/30*.1;

hs=(X.Homework_Assignments[0]+X.Homework_Assignments[1]+X.Homework_Assignments[2]+X.Homework_Assignments[3]+X.Homework_Assignments[4])/500*.3;

in_part=X.In_Class_Participation/100*.05;

mid1=X.Midterm1/100*.15;

mid2=X.Midterm2/100*.15;

fin_proj=X.Final_Project/100*.25;

X.Grade_prcnt= zs+hs+in_part+mid1+mid2+fin_proj;

printf("Calculated percentage = %f ",X.Grade_prcnt);

printf("The Final Grade for %s is ",X.Student_Name);

if(X.Grade_prcnt>=90)

printf("A ");

else if(X.Grade_prcnt>=80)

printf("B ");

else if(X.Grade_prcnt>=70)

printf("C ");

else if(X.Grade_prcnt>=60)

printf("D ");

else

printf("E ");

}

int main()

{

int n,i;

printf("Enter the number of students in the class: ");

scanf("%d",&n);

student_info S[n];

for(i=0;i<n;i++){

printf("Enter in the name of student number %d: ",i+1);

scanf("%s",S[i].Student_Name);

Scan_Student_Info(&S[i]);

}

int student_no;

char response;

do{

printf("Which student's info would you like to display? (1-%d) ",n);

scanf("%d",&student_no);

Print_Student(S[i-1]);

printf("Would you like to print out the information of another student (y/n) ");

fflush(stdin);

scanf("%c",&response);

if(response=='n')

printf("GoodBye ");

}while(response=='y');

return 0;

}