Solved Homework: Question: Please help with c+ program use only c+ and codeblocks. A multiple-choice examination consists of…

Please help with c+ program use only c+ and codeblocks.
A multiple-choice examination consists of 20 questions. Each question has five choices, labeled A, B, C, D and E. All data for that exam is stored in a file exam.txt. The first line of data contains the correct answers to the twenty questions in the first 20 consecutive (one after the other) character positions. For Example:
BECDCBAADEBACBEDDBED
Each subsequent line in the file contains the answers for a single candidate. Data on a line consists of a candidate number (an integer), then by one or more spaces, followed by the twenty answers given by the candidate in the next 20 consecutive character positions. An X is used if a candidate did not answer a particular question. A sample line is as follows:
5555 BECDCXACCAEDCBEDDACB
There can be an unlimited number of candidates. A line containing a “candidate number” 0 indicates the end of the data.
A student’s final score is calculated by adding up the points awarded for all the questions. Points for a question are awarded as follows:
• Correct answer 4 points
• Wrong answer -1 point
• No answer 0 points
Write a c program to process the data in the file exam.txt and print a report that shows:
1. Each candidate number and their final score (the total points obtained by the candidate).
2. The total number of candidates
3. The number of correct responses to each of the 20 questions.
A sample data file and the expected output are given on the next page (note this is for formatting purposes only).
Sample data that can be in the file exam.txt: BACCDEABCEEDCDABBAED 6734 BXCCDAABCEEDCDACBAED 7843 BADCXAABCEXXCDABBAED 2223 BCBAEACCDAEDCDABBAEA 2324 BACXDEABCEEDCDAABAED 3474 BACCDEABCEEDCDABBAED 3434 XADCDAABCEEDCDABBAED 6374 XXXXXCXXXXXXXXXXXAED 3332 BADCDEABCEEDCDADBCEX 3454 BAC C XEABCEEDCXABBAED 0
media%2F156%2F156fde17-447e-48a1-bd65-98

Sample data that can be in the file exam.txt: BACCDEABCEEDCDABBAED 6734 BXCCDAABCEEDCDACBAED 7843 BADCXAABCEXXCDABBAED 2223 BCBAEACCDAEDCDABBAEA 2324 BACXDEABCEEDCDAABAED 3474 BACCDEABCEEDCDABBAED 3434 XADCDAABCEEDCDABBAED 6374 XXXXXCXXXXXXXXXXXAED 3332 BADCDEABCEEDCDADBCEX 3454 BAC C XEABCEEDCXABBAED 0

Expert Answer

answers

C++ Program

#include<iostream>
#include<string>
#include<fstream>
using namespace std;
int main ()
{
string line;
int marks=0;
int numberofcorrectresponses[20]={0};
/*array (initialised to 0) to record number of correct responses to a particular question*/
cout<<“*******MCQ STUDENT EXAM REPORT*******”;
cout<<endl<<“Student number Mark”<<endl;
ifstream myfile (“exam.txt”);
if (myfile.is_open())
{
getline (myfile,line); /*getline gets one line of the file. If used again, it gets next line*/
string correctkey=line; /*here ‘line’ is the first line of text file*/
getline (myfile,line);
int numberofpapers=0;
do
{
for(int i=5; i<25; i++)
{
if(correctkey[i-5]==line[i])
{
marks=marks+4;
numberofcorrectresponses[i-5]++;
}
else if(line[i]==’X’);
else
marks–;
}
cout<<” “<<line[0]<<line[1]<<line[2]<<line[3]<<” “<<marks<<endl;
marks=0;
numberofpapers++;
getline (myfile,line);
}while(int(line[0])!=48); /*int(c) gives ASCII value of c, 48 is ASCII value of 0*/
cout<<endl<<“Total number of examinations marked : “<<numberofpapers;
cout<<endl<<“Number of correct responses for each question:”<<endl;
cout<<“Question: “;
for(int i=1; i<11; i++)
cout<<i<<” “;
cout<<endl<<“#correct: “;
for(int i=0; i<10; i++)
cout<<numberofcorrectresponses[i]<<” “;
cout<<endl<<“Question: “;
for(int i=11; i<21; i++)
cout<<i<<” “;
cout<<endl<<“#correct: “;
for(int i=10; i<20; i++)
cout<<numberofcorrectresponses[i]<<” “;
myfile.close();
}
else
cout<<“There is no file exam.txt”;

return 0;
}

Input

# include< iostream> # include <string> #include<fstream> using namespace std; int main ) string line; int marks=0; int numbe rofcorrectresponses [20]={0}; array anitialised to 0) to record number of correct responses to a particular uestion/ coutくくendl<< Student number Mark<<endl: ifstream myfile (exam.x if (myfile.is_open )) getline (myfile,line) atkine gets one 1ine of the file. If used again, it gets next line/ string correctkey-line: /here wasw is the first line of text file/ getline (myfile, line); int numbe rofpapers#0; do for(int i-5 i<25 i++) if (correctkey[i-5lie[i]) marks=marks+4; numberofcorrectresponses[i-51++ else else if ( line [1]-X ); marks- cout<<<<line [0]<<line [1]<<line [2]<<line [3]<< marks=0; numberofpapers++ getline (myfile, line) <<marks<<endl; /while (int (line [0])!=48); /int (c) gives ASCII value of c, 48 is ASCII value of 07 cout<<endl<<Total number of examinations marked : <<numbe rofpapers; cout<<end!<<Number of correct responses for each question :<<endl ; cout<<Question: ; for (int i=l; İCLI; i++) cout<<i<< coutくくendl<<#correct : ; for (int i=0; 起10; i++) cout<<numberofcorrectresponses [i]<< coutくくend!くくQuestion: . ; for (int i=11; ¡<21; i++) cout<<endl<<#correct : ; for (int i-10: i<20: 1++) coutくくnumberofcorrectresponses [1] << myfile.close ( else cout<< There is no file exam .玉燕. return 0;Output

Buy Essay
Calculate your paper price
Pages (550 words)
Approximate price: -

Help Me Write My Essay - Reasons:

Best Online Essay Writing Service

We strive to give our customers the best online essay writing experience. We Make sure essays are submitted on time and all the instructions are followed.

Our Writers are Experienced and Professional

Our essay writing service is founded on professional writers who are on stand by to help you any time.

Free Revision Fo all Essays

Sometimes you may require our writers to add on a point to make your essay as customised as possible, we will give you unlimited times to do this. And we will do it for free.

Timely Essay(s)

We understand the frustrations that comes with late essays and our writers are extra careful to not violate this term. Our support team is always engauging our writers to help you have your essay ahead of time.

Customised Essays &100% Confidential

Our Online writing Service has zero torelance for plagiarised papers. We have plagiarism checking tool that generate plagiarism reports just to make sure you are satisfied.

24/7 Customer Support

Our agents are ready to help you around the clock. Please feel free to reach out and enquire about anything.

Try it now!

Calculate the price of your order

Total price:
$0.00

How it works?

Follow these simple steps to get your paper done

Place your order

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.

HOW OUR ONLINE ESSAY WRITING SERVICE WORKS

Let us write that nagging essay.

STEP 1

Submit Your Essay/Homework Instructions

By clicking on the "PLACE ORDER" button, tell us your requires. Be precise for an accurate customised essay. You may also upload any reading materials where applicable.

STEP 2

Pick A & Writer

Our ordering form will provide you with a list of writers and their feedbacks. At step 2, its time select a writer. Our online agents are on stand by to help you just in case.

STEP 3

Editing (OUR PART)

At this stage, our editor will go through your essay and make sure your writer did meet all the instructions.

STEP 4

Receive your Paper

After Editing, your paper will be sent to you via email.

× How can I help you?