Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ When an object is falling because of gravity, the following formula can be used to determine the distance the object falls in a specific

C++

"When an object is falling because of gravity, the following formula can be used to determine the distance the object falls in a specific time period:

d=1/2gt^2

The variables in the formula are as follows: d is the distance in meters, g is gravitational acceleration (9.8 m/s/s), and t is the amount of time in seconds that the object has been falling.

Write a function named fallingDistance that accepts an object's falling time in seconds as an argument. The function should return the distance in meters that the object has fallen during that time interval. Write a loop that calls the function with time values 1 through 10 and displays the distance in a 2 column table. One column should be for time, the other for distance. Use to set the output to fixed with a precision of 2, and a column width of 8 for each column."

ATTENTION: I just need help manipulating the setw, here's my code, everything works perfectly, but I didn't set setw to 8 because then it doesn't line up. Please, explain how to fix it. Thanks!

#include #include #include using namespace std;

int time; const double GRAVITY = 9.8; void fallingDistance();

int main() { fallingDistance(); } void fallingDistance() { double distance; cout<<"Time"<

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

Hands On Database

Authors: Steve Conger

1st Edition

013610827X, 978-0136108276

More Books

Students also viewed these Databases questions

Question

Summarize the process of controlling resources

Answered: 1 week ago