
CHAN K.
asked 12/21/20SELECTION CONTROL STRUCTURES
Create a complete C program for lecturers to keep track of students’ assessment.
● Ask the user to enter the type of assessment, either Q for Quiz or A for Assignment.
o Use switch case statement to identify their choice.
o If their choice is Quiz:
▪ Ask the user to enter quiz 1 and quiz 2 marks.
▪ Sum up the marks.
▪ Display the assessment type and total.
o If their choice is Assignment:
▪ Ask the user to enter the assignment marks.
▪ Use if else statement to identify the status of the assignment based
on the table below.
Assignment marks Assignment status
0 to less than 50 Re-do Assignment
50 to less than 70 Good
70 to 100 Excellent
Other values Not available
o Display the assessment type and the assignment status.
o If the user entered other values, display “Invalid assessment code entered”
o Display the results as shown below
Enter type of assesment:Q Enter type of assesment:A
Enter quiz 1 and quiz 2 marks: 7.5 , 10 Enter assignment marks:67
Assesment type:Quiz Assignment type:Assignment
Quiz total:17.50 Status:Good
1 Expert Answer

Patrick B. answered 12/21/20
Math and computer tutor/teacher
#include <stdio.h>
#include <ctype.h>
DoQuiz()
{
float quiz1 = -1;
float quiz2 = -1;
while (quiz1<0)
{
printf("Please input quiz1 mark :>");
scanf("%f",&quiz1);
}
while (quiz2<0)
{
printf("Please input quiz2 mark :>");
scanf("%f",&quiz2);
}
printf(" Assessment type: Quiz \n");
printf(" quiz marks: %6.2f and %6.2f \n ",quiz1,quiz2);
printf(" quiz total: %6.2f \n",(quiz1+quiz2));
}
DoAssignment()
{
float x=-1;
while (x<0)
{
printf("Please input the assignment mark :>");
scanf("%f",&x);
}
printf(" Assessment type: Assignment \n");
printf(" Assignment mark: %6.2f \n",x);
printf(" Status: ");
if ((x>=0) && (x<50))
{
printf(" Re-do Assignment \n");
}
else if ((x>=50) && (x<70))
{
printf(" Good \n");
}
else if ((x>=70) && (x<=100))
{
printf(" Excellent \n");
}
else
{
printf(" Not available \n");
}
}
Go()
{
char assessment_type = '?';
while ((assessment_type != 'Q') && (assessment_type!='A'))
{
printf(" Please input the type of assessment: Q=Quiz A = Assignment :>");
scanf("%c",&assessment_type);
fflush(stdin);
assessment_type = toupper(assessment_type);
}
switch (assessment_type)
{
case 'Q':
{
DoQuiz();
break;
}
case 'A':
{
DoAssignment();
break;
}
default:
{
printf(" Invalid assessment code entered \n");
break;
}
}
}
int main()
{
Go();
}
Still looking for help? Get the right answer, fast.
Get a free answer to a quick problem.
Most questions answered within 4 hours.
OR
Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.
Patrick B.
The source code is posted in the RESOURCES section if you look12/21/20