Please write pseudocode in C code (For Matlab) please use any values for the cou
ID: 3792005 • Letter: P
Question
Please write pseudocode in C code (For Matlab)
please use any values for the course code, quizzes and etc, however state the assumed values.
The following algorithm is designed to determine a grade for a that consists of quizzes, homework, and a final exam: Input course number and name. Input weighting factors for quizzes (WQ), homework exam Input quiz grades and determine an average quiz grade (AQ) Input homework grades and determine an average homework grade (AH) If this course has a final grade, continue to step 6. If not, go to step 9 Input final exam grade (FE) Determine average grade AG according to AG =WQ times AQ + WH times AH + WF times FE/WQ + WH + WF times 100% Go to step 10 Determine average grade AG according to WQ times AQ + WH times AH/WQ + WH times 100% Print out course number, name, and average grade. Terminate computation. Write well-structured pseudocode to implement this algorithm. based on this algorithm. Test it using the following data to calculate a grade without the final exam and a grade with the final exam: WQ = 30: WH = 40; WF = 30; quizzes = 98, 95 90, 60, 99; homework = 98, 95, 86, 100, 100, 77; and final exam = 91Explanation / Answer
(a)
input the course number and name
input the weighting factors WQ, WH, WF
input quiz grades
input homework grades
initialize the averagequizgrade(AQ) to zero
initialize the averagehomeworkgrade(AH) to zero
calculate AQ using AQ = sum of grades of quizzes / number of grades
calculate AH using AH = sum of grades of homework / number of grades
if finalgrade(FE) is available
calculate AG = ((WQ * AQ + WH * AH + WF * FE) / (WQ + WH + WF)) * 100
Print out Course number, name and Average grade in proper format
else
calculate AG = ((WQ * AQ + WH * AH) / (WQ + WH)) * 100
Print out Course number, name and Average grade in proper format
end if statement
(b)
#include <stdio.h>
void main()
{
int i,j;
char str1[10];
int courseNo;
float aq=0;
float ah=0;
float ag=0;
int fe,wq,wh,wf,Qgrade1,Qgrade2,Qgrade3,Qgrade4,Qgrade5, Hgrade1,Hgrade2,Hgrade3,Hgrade4,Hgrade5;
clrscr();
printf(" Enter your Course Number: ");
scanf(" %d ", &courseNo );
printf(" Enter your Name: ");
for( i = 0; i <= 9;i++ )
scanf(" %c ", &str1[i] );
getch();
printf(" Enter the Final Grade if available else enter zero: ");
scanf("%d",&fe);
printf(" Enter the weighing factor for Quiz: ");
scanf("%d",&wq);
printf(" Enter the weighing factor for HomeWork: ");
scanf("%d",&wh);
printf(" Enter the weighing factor for Final Exam: ");
scanf("%d",&wf);
printf(" Enter the grades for Quiz: ");
scanf("%d %d %d %d %d",&Qgrade1,&Qgrade2,&Qgrade3,&Qgrade4,&Qgrade5);
printf(" Enter the grades for Homework: ");
scanf("%d %d %d %d %d",&Hgrade1,&Hgrade2,&Hgrade3,&Hgrade4,&Hgrade5);
aq = (Qgrade1 + Qgrade2 + Qgrade3 + Qgrade4 + Qgrade5) / 5;
ah = (Hgrade1 + Hgrade2 + Hgrade3 + Hgrade4 + Hgrade5) /5;
if (fe!=0)
{
ag = ((WQ * AQ + WH * AH + WF * FE) / (WQ + WH + WF)) * 100;
printf("CourseNumber = %d , Average Grade = %f ",courseNo,ag);
for( j = 0; j <= 9; j++ )
printf("Name = %c ", str1[j] );
}
else
{
ag = ((WQ * AQ + WH * AH) / (WQ + WH)) * 100;
printf("CourseNumber = %d , Average Grade = %f ",courseNo,ag);
for( j = 0; j <= 9; j++ )
printf("Name = %c ", str1[j] );
}
}