Click here to Skip to main content
15,879,348 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
You are required to write a program to mark a multiple choice exam that the students will write. The correct answers are as follows:

 1. E   2. D   3. D
 4. B   5. A   6. C
 7. E   8. B   9. D
10. C  11. D  12. A
13. A  14. D  15. D
16. E  17. A  18. E
19. A  20. D


A student must correctly answer 15 out of 20 questions to pass the exam. The exam questions are printed on paper and the students enter their answers to the questions using the program you write. After the students enter all the answers to the questions the program will either display a message indicating that they passed the exam and the total number of correct answers or a message indicating that they failed the exam and the total number of incorrect answers as well as the list of question numbers that the student missed.

What I have tried:

Don't know how to do this question and it is little difficult for me to solve and little confuse about this.
Posted
Updated 1-Apr-18 12:42pm
v2
Comments
PIEBALDconsult 1-Apr-18 13:18pm    
Write it any way you want. But _you_ have to write it.

Start by reading the inputs from the user, and storing them in an array - that should be simple for you, it's probably just an extension of your previous homework, and storing results in an array.
When he's entered them all, check he's happy with his answers, and then loop through his answers comparing them with the correct values.
Probably the easiest way to do that is to store the answers as an array of characters as well, and that's very simple to do:
C#
char[] correct = "EDDBAC...".ToArray();

Then all you have to do is check his result, and print his grade.

Do it in stages, and test each stage as you go - this isn't complicated, and you should be able t do it pretty quickly with a little thinking.
Give it a try!
 
Share this answer
 
First, write a function that calculates the Levenshtein Distance between two strings.
Levenshtein distance - Wikipedia[^]

Then use it to compare a student's test answers against the answer key.

C#
string key =
@"
 1. E   2. D   3. D
 4. B   5. A   6. C
 7. E   8. B   9. D
10. C  11. D  12. A
13. A  14. D  15. D
16. E  17. A  18. E
19. A  20. D
" ;

string test =
@"
 1. E   2. D   3. D
 4. B   5. A   6. C
 7. A   8. B   9. D
10. C  11. D  12. A
13. A  14. B  15. D
16. E  17. A  18. E
19. A  20. D
" ;

System.Console.WriteLine ( Levenshtein ( test , key ) ) ;


The result is the number of incorrect answers.
Some minor normalization of the strings may be required.

Done.
 
Share this answer
 
v3
Quote:
Don't know how to do this question and it is little difficult for me to solve and little confuse about this.

Think how you would proceed manually, your program will follow the same path.
Think how you would write a procedure of what is the task for someone that can follow simple steps.
...
- get student answer
- save answer for later use
- check if student answer match correct answer.
...

Using some analyze methods will help you, Dijkstra Top-Down method is a good start.
https://en.wikipedia.org/wiki/Top-down_and_bottom-up_design[^]
https://en.wikipedia.org/wiki/Structured_programming[^]
https://en.wikipedia.org/wiki/Edsger_W._Dijkstra[^]
https://www.cs.utexas.edu/users/EWD/ewd03xx/EWD316.PDF[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900