A multiple-choice examination consists of 20 questions. Each question has five choices, labeled A, B, C,...

90.2K

Verified Solution

Question

Programming

A multiple-choice examination consists of 20 questions. Eachquestion has five choices, labeled A, B, C, D and E. All data forthat exam is stored in a file exam.txt. The first line of datacontains the correct answers to the twenty questions in the first20 consecutive (one after the other) character positions.
For Example: BECDCBAADEBACBEDDBED

Each subsequent line in the file contains the answers for a singlecandidate. Data on a line consists of a candidate number (aninteger), then by one or more spaces, followed by the twentyanswers given by the candidate in the next 20 consecutive characterpositions. An X is used if a candidate did not answer a particularquestion. 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 pointsawarded for all the questions. Points for a question are awarded asfollows:
• 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 andgenerate a report that shows:
1. Each candidate number and their final score (the total pointsobtained by the candidate).
2. The total number of candidates.
3. The number of correct responses to each of the 20questions.
4. The minimum score attained by a student in the exam.
5. The maximum score attained by a student in the exam.
6. The average score attained by a student in the exam.

The report must be written to a file called Report.txt.

Answer & Explanation Solved by verified expert
4.0 Ratings (747 Votes)
using Systemusing SystemCollectionsGenericusing SystemIOusing SystemLinqusing SystemTextusing SystemThreadingTasksnamespace smallcsarpclass Programstatic void Mainstring argsConsoleWriteEnter the file name enter file nameString fileName ConsoleReadLine raed alla line in a stringstring lines FileReadAllLinesfileName store all correct answerschar correctAnswers lines0ToCharArray to collect correct answersint noOfcorrectAns new int20 minimum and maximum valueint max 0 min 100 student numberint stdNos new intlinesLength1 number of student    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Zin AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students

Q

Hartman, Inc. has prepared the following comparative balance sheets for 2017 and 2018:                                                                                                           2018                      2017                Cash                                                                                    $   282,000             $  153,000          Accounts receivable                                                                 139,000                 117,000          Inventory                                                                                   150,000                 180,000          Prepaid expenses                                                                      18,000                   27,000          Plant assets                                                                           1,295,000              1,050,000          Accumulated depreciation                                                       (450,000)              (375,000)          Patent                                                                                       153,000                 174,000                                                                                                       $1,587,000            $1,326,000          Accounts payable                                                                $   153,000            $   168,000          Accrued liabilities                                                                       60,000                   42,000          Mortgage payable                                                                          —                     450,000          Preferred stock                                                                         525,000                      —          Additional paid-in capital—preferred                                       120,000                      —          Common stock                                                                         600,000                 600,000          Retained earnings                                                                    129,000                   66,000                                                                                                       $1,587,000            $1,326,000 1.   The Accumulated Depreciation account has...

Accounting
Q

-/1

Accounting