Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

c++ how to get sample run2? Question 2(5pt): Braking Distance Displacement, D (i.e. a distance) for a braking vehicle can be calculated with the initial

c++ how to get sample run2?

image text in transcribed

image text in transcribedimage text in transcribed

Question 2(5pt): Braking Distance Displacement, D (i.e. a distance) for a braking vehicle can be calculated with the initial velocity, I, the final velocity, F, and deceleration, a. (F2 12) (-2a) Write a function called displacement that takes as parameters: initial velocity, I, final velocity F, and deceleration a. Function specifications: Your function must be named displacement Your function takes three parameters (all double, in this order) o Initial velocity I o Final velocity F o Deceleration a Your function should return the appropriate displacement, D, of the vehicle as double. If one or more values are invalid, the function print all the error messages in this order and return 0. If your function receives negative velocities then it must print "Velocity should be greater than zero." If your function receives a zero deceleration then it must print "No brakes were applied." If your function receives a negative deceleration then it must print "The vehicle is speeding up." If your function receives F > I then it must print Error in acceleration values." For example: Bob is riding his bicycle to the store at a velocity of 4 m/s, when an aardvark runs out in front of him. He quickly brakes to a complete stop, with a deceleration of 2 m/s. What is his displacement? Note that because Bob is stopped, the final velocity, F = 0. His initial velocity, I = 4 m/s. The deceleration is 2 m/s. Therefore the function should return 4. (02 4?) 4 (-2-2) = 4 Sample run 1 (bold is user input) Enter initial velocity: 10 Enter final velocity: 1 Enter deceleration: 5 Displacement is 9.9 Sample run 2 (bold is user input) Enter initial velocity: 1 Enter final velocity: 2 Enter deceleration: 0 No brakes were applied. Error in acceleration values

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

Larry Ellison Database Genius Of Oracle

Authors: Craig Peters

1st Edition

0766019748, 978-0766019744

More Books

Students also viewed these Databases questions

Question

In Problems 914, evaluate each factorial expression. 9! 6!

Answered: 1 week ago

Question

Presentations Approaches to Conveying Information

Answered: 1 week ago