subject
Computers and Technology, 30.07.2021 05:00 Yasin36

Your program will calculate the distance an object travels (in meters) on Earth for a specified number of seconds. You will also calculate the distance traveled on the Moon (in meters) for the specified number of seconds. Your program must have the main function and, at least, the following four additional functions. The signatures for these functions must be as follows:
double readSeconds()
double calculateEarthDistance(double seconds)
double calculateMoonDistance(double seconds)
void displayResults(double seconds, double earthDistance, double moonDistance)
The readSeconds function will be an input function that will read in a double value from cin and return that value back to main.
The calculateEarthDistance function will calculate the distance an object falls (on Earth) during the specified number of seconds.
The calculateMoonDistance function will calculate the distance an object falls (on the Moon) during the specified number of seconds.
The displayResults function that will display the number of seconds an object has fallen as well as the distance the object has fallen on the Earth and on the Moon.
You can have additional function is needed.
Here is a summary of the processing that is required in the various functions:
double readSeconds()
This function reads in a value from cin. If the value is less than zero the function should output a message.
The value read in (valid or not) should be returned to the calling function.
The prompt from the function should be:
Enter the time (in seconds)
If the value is less than zero you should output the following message.
The time must be zero or more
double calculateEarthDistance(double seconds)
This function calculates the distance traveled (on Earth) during the number of seconds pass in as a parameter. The distance is calculated in meters and is returned to the calling function.
The formula is:
d = 0.5 * g * pow(t, 2)
Where d is distance (in meters), t is time (in seconds) and g is 9.8 meters / second squared (the acceleration due to gravity on the earth).
Use good variable names and not just d, g and t. Use double values for your calculations.
double calculateMoonDistance(double seconds)
This function calculates the distance traveled (on the Moon) during the number of seconds pass in as a parameter. The
distance is calculated in meters and is returned to the calling function.
The formula is the same as the formula on Earth, but the value of g is different. For the Moon g is 1.6 meters / second squared.
Use good variable names and not just d, g and t. Use double values for your calculations.
void displayResults(double seconds, double earthDistance, double moonDistance)
The displayResults function takes three parameters of type double. The first is the number of seconds and the second is the distance traveled on the Earth, and the third parameter is the distance traveled on the Moon. Note that the displayResults function must be passed the values for seconds, earthDistance, and moonDistance. The displayResults function MUST NOT call readSeconds, calculateEarthDistance, or calculateMoonDistance.
The output is the text:
The object traveled xxx. meters in zz. zz seconds on Earth
The object traveled yy. meters in zz. zz seconds on the Moon
Note that the distance is output with four digits to the right of the decimal point while seconds is output with two digits to the right of the decimal point. Both are in fixed format.
Assume that the number of seconds is 10.5, the output would be:
The object traveled 540.2250 meters in 10.50 seconds on Earth
The object traveled 88.2000 meters in 10.50 seconds on the Moon
int main()
The main function will be the driver for your program.
First you need a loop that will process input values until you get an input value that is equal to 0. You will get this input value by calling the readSeconds function.
If the value is greater than zero the main function needs to call the calculateEarthDistance, calculateMoonDistance, and displayResults functions.
If the value is zero the loop should end and your program should then end.
Note that all of the required non-main functions are called from main.
For the following sample run assume the input is as follows:
-12.5
-3.5
10.5
4.2
0

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 23:30
Define a function printfeetinchshort, with int parameters numfeet and numinches, that prints using ' and " shorthand. ex: printfeetinchshort(5, 8) prints: 5' 8"
Answers: 1
question
Computers and Technology, 24.06.2019 02:00
Write an expression that will cause the following code to print "equal" if the value of sensorreading is "close enough" to targetvalue. otherwise, print "not equal". ex: if targetvalue is 0.3333 and sensorreading is (1.0/3.0), output is:
Answers: 1
question
Computers and Technology, 24.06.2019 02:10
Which sentences describe the things you need to ensure while creating a sketch and a drawing? while an artistic or creative drawing is a creative expression, a technical drawing is an informative expression. you need to create accurate and neat drawings to convey accurate information. a technical drawing clearly conveys its meaning or information, and does not leave room for interpretation maintain a good speed while creating drawings
Answers: 1
question
Computers and Technology, 24.06.2019 09:50
Suppose you are an ad-serving company and you maintain a log of cookie data for ads you serve to the web pages for a particular vendor (say amazon). a. how can you use this data to determine which are the best ads? b. how can you use this data to determine which are the best ad formats? c. how could you records of past ads and ad clicks to determine which ads to send to a given ip address? d. how could you use this data to determine how well the technique you used in your answer to part c was working? e. how could you use this data to determine that a given ip address is used by more than one person? f. how does having this data give you a competitive advantage vis-à-vis other ad-serving companies?
Answers: 2
You know the right answer?
Your program will calculate the distance an object travels (in meters) on Earth for a specified numb...
Questions
question
Arts, 01.11.2020 20:10
question
English, 01.11.2020 20:10
question
Mathematics, 01.11.2020 20:10
question
Advanced Placement (AP), 01.11.2020 20:10
question
Mathematics, 01.11.2020 20:10
question
English, 01.11.2020 20:10
Questions on the website: 13722367