computer science

Question #2 Recursion! REQUIRED FOR ALL STUDENTS! Solve each of the three (3) programs below. You only need to provide three (3) numbers as your answer – one for 2a, one for 2b, and one for 2c.

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper

Code for 2a:

start

        output recursiveA(2)

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper

stop

num recursiveA(num x)

        Declarations

             num result

        if x = 1 then

            result = x

        else

            result = x * (recursiveA(x-1))

        endif

return result

 

Code for 2b:

start

        output recursiveB(0)

stop

num recursiveB(num x)

        Declarations

            num result

        if x = 0 then

            result = x        else

            result = x * (recursiveB(x-1))

        endifreturn result

 Code for 2c:

start

        output recursiveC(2)

stop

num recursiveC(num x)

        Declarations            num result        if x = 0 then            result = x        else

            result = x * (recursiveC(x-1))

        endifreturn result 

Question #3  Create the pseudocode for a game application that contains an array of five (5) multiple-choice questions related to your favorite hobby. Each question contains four answer choices – A…, B…, C…, D… (the …’s are your potential answers including the correct answer). All four (4) choices for each question should be stored in a parallel array. Also create another parallel array that holds the correct answer to each question—A, B, C, or D. NOTE: all arrays are single-dimension.

When a player starts (launches) this game app, pass each question to a method that displays the question and accepts the player’s answer (A, B, C, or D). If the player does not enter a valid (not necessarily a correct) answer choice, force the player to reenter the choice until the player enters a valid (might not be a correct answer) value of A, B, C or D. Return the player’s valid (but not necessarily correct) answer to the main program. After the player’s answer is returned to the main program, pass it and the correct answer to a method that determines whether the values are equal and displays an appropriate message. After the player answers all five questions, display the number of correct and incorrect answers that the player chose. Be sure to use the concepts of this chapter where appropriate – arguments/parameters, return values, void, etc.

  

Still stressed with your coursework?
Get quality coursework help from an expert!