
Patrick B. answered 12/20/20
Math and computer tutor/teacher
It is unclear what is required for the "assignment" portion of this program..
Multiple marks are input for each assignment and the assignment status is output
FOR EACH assignment mark...I am ASSUMING!
It would be nice to know how many assignments there are...
the code blocks below also reports the average of the assignment marks
for up to 100 marks..
the source code has been uploaded to the RESOUCES section under this link
#include <stdio.h>
#include <string.h>
#include <ctype.h>
DoQuiz()
{
float quiz1=-1,quiz2=-1;
while (quiz1<0)
{
printf(" Please input quiz #1 mark :>");
scanf("%f",&quiz1);
}
while (quiz2<0)
{
printf(" Please input quiz #2 mark :>");
scanf("%f",&quiz2);
}
float quizTotal = quiz1+quiz2;
printf(" The quiz total of %6.2f and %6.2f is %6.2f \n",quiz1,quiz2,quizTotal);
}
DoAssignment()
{
float marks[100];
int count=0;
int iLoop;
float curMark=0;
double grandTotal=0;
while (curMark>=0)
{
printf("Input the assignment marks ; conclude the input with -1 :>");
scanf("%f",&curMark);
if (curMark>-1)
{
marks[count++] = curMark;
grandTotal += curMark;
}
}
double meanAvg = (count>0) ? grandTotal/count : 0;
for (iLoop=0; iLoop<count; iLoop++)
{
char strStatus[25];
memset(strStatus,0,25);
float curMark = marks[iLoop];
if (curMark<50)
{
strcpy(strStatus,"RE-DO the ASSIGNMENT \n");
}
else if ((curMark>=50) && (curMark<70))
{
strcpy(strStatus,"GOOD \n");
}
else if ((curMark>=70) && (curMark<=100))
{
strcpy(strStatus,"EXCELLENT \n");
}
else
{
strcpy(strStatus,"UNAVAILABLE \n");
}
printf(" Assignment mark # %d : %6.2lf : %s ",(iLoop+1),curMark,strStatus);
}
printf("-------------------------------\n");
printf(" The grand total is %6.2lf \n",grandTotal);
printf(" The average is %6.2lf \n",meanAvg);
}
Go()
{
char assessment_type='?';
while ((assessment_type!='Q') && (assessment_type!='A'))
{
printf("Please input the assessment type Q for Quiz or A for Assignment :>");
scanf("%c",&assessment_type);
assessment_type = toupper(assessment_type);
fflush(stdin);
}
switch(assessment_type)
{
case 'Q':
{
DoQuiz();
break;
}
case 'A':
{
DoAssignment();
break;
}
default:
{
printf(" Invalid assessment code entered \n");
break;
}
} //switch
}
int main()
{
Go();
}
Lavenesh D.
Hi tried your answer is quite similar to what the question is asking. I have upload a new question where it say the exact thing the c programs wants me to do. Hope you could see that n revert back12/20/20