Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C++ Displacement, D (i.e. a distance for a braking vehicle can be calculated with the initial velocity, I, the final velocity, F, and deceleration,

In C++

image text in transcribedimage text in transcribed

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) (-2.a 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 42) (-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

Students also viewed these Databases questions

Question

5. Identify and describe nine social and cultural identities.

Answered: 1 week ago

Question

2. Define identity.

Answered: 1 week ago

Question

4. Describe phases of majority identity development.

Answered: 1 week ago