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= /2 gt? The variables in the formula are as follows: d is the distance in meters, g is 9.8, 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 me that time interval. Write a program that demonstrates the function by prompting the user for the total time and calling the function in a loop that pass increments as the argument and displays the elapsed time and return value. The output should like the output below. INPUT VALIDATION: The time entered by the user should be a number, and it should be greater than 0. Please enter the total falling time: 20 Time Distance 0.00 5.00 10.00 15.00 20.00 userêmimir: ~/csci_10150c_fall_2020/m05_programming_assignment_1 > ./a.out Please enter the total falling time: 23 0.00 122.50 490.00 1102.50 1960.00 rime Distance 0.00 5.00 10.00 15.00 20.00 23.00 0.00 122.50 490.00 1102.50 1960.00 2592.10 Please enter the total falling time: -1 Your time should be greater than 0 Please enter the total falling time: a That is not a number! Please try again. nlease tetal falling tim

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

c++ 

falling distance

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 = \frac{1}{2}gt^2 \]

The variables in the formula are as follows: \( d \) is the distance in meters, \( g \) is 9.8, 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 fell during that time interval. Write a program that demonstrates the function by prompting the user for the total time and calling the function in a loop that passes the values 0 through the time in increments as the argument and displays the elapsed time and return value. Output should be formatted as shown below.

**INPUT VALIDATION:** The time entered by the user should be a number, and it should be greater than 0.

### Sample Output

#### Case 1:
```
Please enter the total falling time: 20

Time         Distance
**************************
0.00         0.00
5.00         122.50
10.00        490.00
15.00        1102.50
20.00        1960.00
```

#### Case 2:
```
Please enter the total falling time: 23

Time         Distance
**************************
0.00         0.00
5.00         122.50
10.00        490.00
15.00        1102.50
20.00        1960.00
23.00        2592.10
```

#### Invalid Input Handling:
```
Please enter the total falling time: -1

Your time should be greater than 0
Please enter the total falling time: a

That is not a number! Please try again.
Please enter the total falling time: 2
```

The samples demonstrate the program's ability to calculate and display the distance fallen at regular intervals of time and handle invalid input scenarios effectively.
Transcribed Image Text: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 = \frac{1}{2}gt^2 \] The variables in the formula are as follows: \( d \) is the distance in meters, \( g \) is 9.8, 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 fell during that time interval. Write a program that demonstrates the function by prompting the user for the total time and calling the function in a loop that passes the values 0 through the time in increments as the argument and displays the elapsed time and return value. Output should be formatted as shown below. **INPUT VALIDATION:** The time entered by the user should be a number, and it should be greater than 0. ### Sample Output #### Case 1: ``` Please enter the total falling time: 20 Time Distance ************************** 0.00 0.00 5.00 122.50 10.00 490.00 15.00 1102.50 20.00 1960.00 ``` #### Case 2: ``` Please enter the total falling time: 23 Time Distance ************************** 0.00 0.00 5.00 122.50 10.00 490.00 15.00 1102.50 20.00 1960.00 23.00 2592.10 ``` #### Invalid Input Handling: ``` Please enter the total falling time: -1 Your time should be greater than 0 Please enter the total falling time: a That is not a number! Please try again. Please enter the total falling time: 2 ``` The samples demonstrate the program's ability to calculate and display the distance fallen at regular intervals of time and handle invalid input scenarios effectively.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Function Arguments
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education