use target vocabulary, such as index and parallel list, while describing app features and User Interface with the support of concept definitions and vocabulary notes from this lesson
In the app, you will construct 3 separate lists for the questions, answers, and the names of image files. The first question in the question list corresponds to the first answer in answer list and the first image in the image list. This parallel setup allows you to use an index variable to associate each question with its corresponding answer and image. For example, when the index variable has the value 2, it is referring to the second question, second answer, and second image.
As you might have noticed, if the answer is βAlan Turingβ and the user types in βalan turingβ, the answer will be marked incorrect. Thatβs not very nice for the user. To remedy this problem you will want to convert both the userβs answer and the stored answer to upper case βALAN TURINGβ. (HINT: use the upcase block in the Text drawer to convert both strings.)
When the user gets an incorrect answer, instead of just reporting βincorrectβ, use a join block to also display the correct answer. For example, βSorry, that is incorrect. The correct answer is Grace Hopper.β
Add RandomButton to the app that when clicked will display a random question from the quiz. (HINT: You could use some new blocks from the List drawer such as a pick a random item block fed into an index in list thing block to set the index randomly.)
Add a fourth question (and answer and image) to the quiz. Research famous computer scientists on the Web to find a fourth person. (HINT: You should only have to modify the 3 lists and upload an image file. The code should work with any number of questions as long as you used the length of list block instead of hard coding in the number 3 for the number of questions.)
Subsection3.11.4Quiz App Extensions with Search Procedure
If/else Scoring Algorithm: Modify your app to keep score of how many questions are answered correctly or incorrectly. Be sure to restrict it so that the quiz taker can only receive credit for answering each question once (i.e., if there are three questions, the quiz taker can only be credited with three correct answers). Use this short handout to guide you with this project.
Loop Algorithm for Searching: Add a keyword search capability to your app. For example, if the user types in NASA and clicks on the search button, you should find the question or answer with the word NASA in it and show that question. This will be a linear search through the parallel question and answer lists using a loop. Use this short handout to guide you with this project.
Your Own Quiz App: Use the Quiz App as a template to create a quiz on a topic of your own choosing. Besides changing the questions, answers, and pictures, add at least one enhancement to the app. Be creative!
Consider the search procedure that you wrote in the quiz app.. Describe the functionality provided by this procedure. Explain the advantages of implementing this functionality as a procedure. Describe how the program would be coded if this functionality was not in a procedure. What are the benefits of using procedural abstraction in your code?
Consider the search procedure that you wrote in the quiz app. Write two calls to your procedure that each cause a different code segment in the procedure to execute. (Hint: whether the search keyword is found or not.) Describe the expected behavior of each call. Describe why this is a good use of procedural abstraction. If it is not possible for two calls to your procedure to cause different code segments to execute, explain why this is the case for your procedure.