A computer program is designed to simulate horses doing show jumping. In show jumping, horses jump over obstacles called fences. A horse successfully jumps a fence if it does not knock the fence down. The program is written using Object-Oriented Programming (OOP). The class Horse stores data about the horses. The chance of a horse jumping a fence without knocking it down is calculated as follows. If the height of the fence is more than the maximum height a horse can jump, the success percentage is $$\(20 \%\)$$ of the horse's PercentageSuccess. The risk does not affect this value. If the height of the fence is less than or equal to the maximum height a horse can jump, the risk gives a modifier value to multiply with the horse's PercentageSuccess. The risk values and their modifiers are given in this table: For example: - The horse Jet has PercentageSuccess of 65 and MaxFenceHeight of 160. - A fence has a height of 140 and a risk of 3 . - The height of the fence is less than the horse's MaxFenceHeight, therefore the risk is used. - $$\(\quad\)$$ The risk of 3 gives the modifier 0.8. - The modifier 0.8 is multiplied by the horse's PercentageSuccess of 65 , which gives 52 . - The chance of the horse successfully jumping this fence is $$\(52 \%\)$$. The method Success () in the Horse class: - takes the height and risk of a fence as parameters - calculates the percentage chance of success for that horse jumping the fence without knocking it down - returns the calculated percentage chance of success as a real number. Write program code for success (). Save your program. Copy and paste the program code into part 2(d) in the evidence document.

Computer Science
IGCSE&ALevel
CAIE
Exam No:9618_w24_qp_41 Year:2024 Question No:2(d)

Answer:





Knowledge points:

19.1 Algorithms
20.1 Programming Paradigms

Solution:

Download APP for more features
1. Tons of answers.
2. Smarter Al tools enhance your learning journey.
IOS
Download
Android
Download
Google Play
Download