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

PLEASE USE C++ PRINTF, SCANF. Do not use cout or cinn. If possible do not use \"

ID: 3603892 • Letter: P

Question

PLEASE USE C++ PRINTF, SCANF. Do not use cout or cinn.

If possible do not use " strtok command".
I also use Visual basic 2015.

Multiple Choice Exam A local High School gives multiple choice exams and wants a way to automate the process of grading and scoring the exams. The exams are 20 questions in length and all questions have 4 possible answers in the range of A-D. Write a program to ask the user for the student's full name and their answers to the 20 questions. Store their answers in an array. Create another array that holds the correct answers. The correct answers are: 11 B, 12 = C, 13 = D, 14 A, 15 = D, 16 = C, 17=C, 18 B, 19 = D, 20 = A Allow the user to enter the answers in either uppercase or lowercase, and then convert the answer to uppercase. Next, validate that the answer is in the correct range of A-D, and if not, re-ask for the answer until an answer in the correct range is entered. After the conversion to uppercase and the validation, compare the answer to the correct answer and keep track of the number of correct answers After all the questions have been answered, display each question and whether or not is was answered correctly. Then display the number of correct answers, the number of incorrect answers, whether the student passed the exam or not, what their score was, and for failing scores what the minimum passing score needed to be. A score of 75% or better is required to pass the exam. Format the numbers to 0 decimal places Put the entire program in a sentinel-controlled loop so that after the 1t student's answers are entered and scored the program will ask for the next student's name and their answers. Quit the program when nothing is entered for the student's name. Store in constants The size of the arrays The score needed to pass the exam. Hints: . Use fgets () to get the student's full name The sentinel-controlled loop's condition should be while (studentName[00) Don't forget to reset the number of correct answers for each student First, get the student's answer to a question and store it in the array Then get the answer out of the array, convert it to uppercase, and store it back in the array - The condition to validate the answers should be while {answers [1] 'D') When calculating the student's score, cast one of the numbers into a double so that the result of the division is a double Before getting the next student's name at the end of the sentinel-controlled loop, execute a scanf(studentName [0]) statement to 'clear the buffer (otherwise, the last

Explanation / Answer

Solution:

code:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define SCORE_NEEDED 75
#define SIZE_OF_ARRAY 20
int main()
{
//Variable for student name
char studentName[30];

//Char array for correct answers
char correctAnswers[SIZE_OF_ARRAY]= {'B','D','A','A','C','A','B','A','C','D','B','C','D','A','D','C','C','B','D','A'};
//Char array for users answers
char userAnswers[SIZE_OF_ARRAY],i=0;

//Variable to store correct answers
int totalCorrectAnswers=0;

//Ask user to enter name
printf("Enter the student's full name (enter nothing to end): ");
fgets(studentName,(int) sizeof(studentName),stdin);
while(studentName[0]!='' && studentName[0]!=' ')
{
//Print the student name, use strtok to remove new line character from student name which was entered because of using fgets
printf("Enter %s's 20 answers: ",strtok(studentName, " "));
//Ask user to enter 20 answers
for(i=0; i<SIZE_OF_ARRAY; i++)
{
printf("Enter answer #%d: ",i+1);
scanf(" %c",&userAnswers[i]);
//Store answer in userAnswers array after converting in uppercase
userAnswers[i]=toupper( userAnswers[i]);

//Check if answer is valid, if not ask to enter again
while(userAnswers[i]<'A' || userAnswers[i]>'D')
{
printf("The answer entered was not in the range A-D. ");
printf("Please re-enter answer #%d: ",i+1);
scanf(" %c",&userAnswers[i]);
userAnswers[i]=toupper( userAnswers[i]);
}
}


//Now, check for correct answers by compairing values in correctAnswers and userAnswers
for(i=0; i<SIZE_OF_ARRAY; i++)
{
//If values matches, increment totalCorrectAnswers
if(correctAnswers[i]==userAnswers[i])
{
totalCorrectAnswers+=1;
printf(" Question #%d - correct",i+1);
}
else
{
printf(" Question #%d - incorrect",i+1);
}
}

//Print the total number of correct answers
printf(" %s had %d correct answers and had %d incorrect answers. ",studentName,totalCorrectAnswers,20-totalCorrectAnswers);

//Find percent of correct answers
double percent=((double)totalCorrectAnswers/20)*100;

//If percent>=75, means pass else fail
if(percent>=SCORE_NEEDED)
{
printf(" The student had passed the questions with a score of %1.0f%%! ",percent);
}
else
{
printf(" The student did not pass the questions. Their score was %1.0f%%. ",percent);
printf("A score of 75%% or better is required to pass. ");
}

//Re-assign totalCorrectAnswers=0 to store correct answers for another student
totalCorrectAnswers=0;
scanf("%c",&studentName[0]);

printf("Enter the student's full name (enter nothing to end): ");
fgets(studentName,(int) sizeof(studentName),stdin);
}
return 0;
}

Please upvote.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote