Home /
Expert Answers /
Computer Science /
write-a-method-for-a-student-who-is-taking-a-multiple-choice-test-and-has-not-studied-so-wants-to-c-pa294

Write a method for a student who is taking a multiple-choice test and has not studied, so wants to choose all of their answers randomly. The method will take as parameters the number of possible choices for each question and return 10 answers as a string, with each answer separated by a space. For example, if each question has 4 answer choices (where choice A=1, choice B=2, choice C=3, and choice D=4), the method call would be problem4_chooseAnswers(4) and a possible result is "4 3 3 1 2 2 1 4 4 3". So the student would then fill in choice D for question 1, choice C for question 2, choice C for question 3, choice A for question 4, etc. Inside your method, construct an object of the Random class (see the Java API docs) and invoke an appropriate method to generate each answer choice. Assume the input value for numChoices will always be >= 1.