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: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students