Question
Examine the given information and answer questions that follow. The coefficient of restitution of a ball, a number between 0 and 1, specifies how much
Examine the given information and answer questions that follow.
The coefficient of restitution of a ball, a number between 0 and 1, specifies how much energy is conserved when the ball hits a rigid surface. A coefficient of 0.9, for instance, means a bouncing ball will rise to 90% of its previous height after each bounce. The coefficient of restitution of a tennis ball, basketball, super ball and softball are 0.7, 0.75, 0.9, and 0.3 respectively. These values are stored in the array, coefOfRestitution.
double coefOfRestitution[4] = {0.7, 0.75, 0.09, 0.3};
The requirements are to input the type of ball and an initial height, and report how many times a ball bounces when dropped from its initial height before it rises to a height of less than 10 centimetres. Also report the total distance travelled by the ball before this point. Data validation is performed for the input for type of ball to be between 0 and 3.
(a) Develop a function, validate() that validates the input for type of ball. The valid values are between 0 and 3. The function prototype is bool validate(int); The input parameter is the input value for type of ball.
(7 marks)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started