Question: Modify Solution 2 shown earlier in Figure 6-4. The solution should now keep track of the number of times Sahirahs laser beam missed the spider.
Modify Solution 2 shown earlier in Figure 6-4. The solution should now keep track of the number of times Sahirah’s laser beam missed the spider. After saying “You are safe now. The spider is dead.”, Sahirah should say one of the following: “I got him immediately.”; “I missed him one time.”; or “I missed him x times.” (where x is the value in the counter).

Problem Specification A superheroine named Sahirah must prevent a poisonous yellow spider from attacking King Khafra and Queen Rashida. Sahirah has one weapon at her disposal: a laser beam that shoots out from her right hand. Sahirah can take as many shots as needed to destroy the spider, which is flying around the palace looking for the king and queen. Before taking each shot, she needs to position both her right arm and her right hand toward the spider. When the laser beam hits the spider, she should return her right arm and right hand to their original positions and then say "You are safe now. The spider is dead." Solution 1 1. position both your right arm and your right hand toward the spider 2. shoot a laser beam at the spider 3. repeat while the laser beam did not hit the spider looping condition specifies when to continue position both your right arm and your right hand toward the spider- shoot a laser beam at the spider- end repeat while 4. return your right arm and your right hand to their original positions 5. say "You are safe now. The spider is dead." loop body loop exit condition specifies when to stop Solution 2 1. position both your right arm and your right hand toward the spider 2. shoot a laser beam at the spider 3. repeat until the laser beam hits the spider- position both your right arm and your right hand toward the spider- shoot a laser beam at the spider- end repeat until 4. return your right arm and your right hand to their original positions 5. say "You are safe now. The spider is dead." loop body
Step by Step Solution
3.29 Rating (152 Votes )
There are 3 Steps involved in it
1 Initialize counter to 0 2 Position both your right ar... View full answer
Get step-by-step solutions from verified subject matter experts
