Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You are working on the newest racing game. Your part is to calculate the speed the car is moving based on acceleration and time. The

You are working on the newest racing game. Your part is to calculate the speed the car is moving based on acceleration and time. The game determines the acceleration based on how hard the user is pressing the analog trigger button or racing pedal. While the rest of the game is being written, you will write the functions that meet the specifications below.
Function 1
Function Name
speedDueToAcceleration
Parameters
acceleration : double
time : int
Return Type
double
Description
Takes an acceleration and time value and returns the speed. The time is given in seconds and the acceleration is given in m/s2. The formula for calculating speed is s=at
s
=
a
t
where a is acceleration and t is time.
Function 2
Function Name: accelerationFromButton
Parameters
buttonForce : double
Return Type
double
Description
Takes a double between 0 and 10 representing how hard the user is pressing the acceleration button and converts it to an acceleration in m/s2. Use the formula a=f0.463
a
=
f
0.463
where f is the buttonForce and 0.463 is the force to acceleration conversion constant.
Until your functions can be incorporated in the rest of the game, create a main that prompt for the button force between 0 and 10 and the total time in seconds. Write a program C++ that converts the button force to acceleration and then loop starting at time 0 until the time entered by the user in 3-second increments. Print a table that shows the speed the vehicle will be traveling at each iteration of the loopformat the speed and acceleration numbers to 3 decimal places. Ensure the time entered by the user is the final value shown in the table, even if the total time is not divisible by 3. The final value should not be duplicated.
To make sure your functions are compatible with the rest of the game, they will be unit-tested.
Input Validation:
You should ensure that the user input does not cause input failure. You should also ensure that the button force is between 0 and 10 and that the total time is greater than 0.
Sample Output:
Enter the button force between 0 and 10: 5
Enter the total acceleration time in seconds: 29
Acceleration is 2.315 m/s^2
Time in s Speed in m/s
******************************
00.000
36.945
613.890
920.835
1227.780
1534.725
1841.670
2148.615
2455.560
2762.505
2967.135

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions