Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

rite Function #1: This function answers the question How much do you weigh on another planet? Input parameters: Weight on Earth (a floating point value)

image text in transcribed

rite Function #1: This function answers the question "How much do you weigh on another planet?" Input parameters: Weight on Earth (a floating point value) and planet selection (an integer) Return value: Weight on other planet selected by user (a floating point value) Data that should be inside the function: For each planet, the ratio of that planet to Earth's gravity Hint: an array makes this task easy Function #2: This function converts some number of Earth days, hours, minutes, and seconds into total seconds. Input parameters: Numbers of days, hours, minutes, and seconds (all floating point values) Return value: Total number of seconds (a floating point value) Data that should be inside the function: Conversion factors for converting time units (ex. 1hr-60min) Note: This function may be called directly from the main function as a menu option, or from function #3 below to assist with converting days to seconds. Function #3: This function computes how much time (relative to Earth days) it takes some planet to orbit the sun. Input parameter: Planet selection (an integer) Return value: Total number of seconds the planet takes to orbit the sun (a floating point value) Data that should be inside the function: The orbital time of each planet, which may be expressed as ome number of Earth days. Hint: an array makes this task easy Note: This function will call function #2 (when that function is available) to handle the task of converting the number of days, O hours, 0 minutes, and 0 seconds to a total number of seconds. When function #2 returns the converted time, this function can then return the resulting total number of seconds to the main function The main function should handle all user input and output display statements. The general structure of main is as follows: * * . Display a welcome to the user Prompt the user to select from a menu of choices, which correspond to the three task functions. Read in the user's answer and test to determine the user's choice of function. (A switch or if-else lf the user enters an invalid choice not available on the menu, an error message should be displayed. Based on the user's valid choice, prompt the user for data needed by the task function, and read in the data Call the appropriate task function to complete the task, passing the data read in. Display the answer returned from the task function, including text explaining what is being displayed. Test your program by selecting a different function each time. Also test with different input values to verify that your functions supply the correct arithmetic answers. Extra credit: Add a loop to repeat the menu as long as the user enters an invalid choice. * * * * rite Function #1: This function answers the question "How much do you weigh on another planet?" Input parameters: Weight on Earth (a floating point value) and planet selection (an integer) Return value: Weight on other planet selected by user (a floating point value) Data that should be inside the function: For each planet, the ratio of that planet to Earth's gravity Hint: an array makes this task easy Function #2: This function converts some number of Earth days, hours, minutes, and seconds into total seconds. Input parameters: Numbers of days, hours, minutes, and seconds (all floating point values) Return value: Total number of seconds (a floating point value) Data that should be inside the function: Conversion factors for converting time units (ex. 1hr-60min) Note: This function may be called directly from the main function as a menu option, or from function #3 below to assist with converting days to seconds. Function #3: This function computes how much time (relative to Earth days) it takes some planet to orbit the sun. Input parameter: Planet selection (an integer) Return value: Total number of seconds the planet takes to orbit the sun (a floating point value) Data that should be inside the function: The orbital time of each planet, which may be expressed as ome number of Earth days. Hint: an array makes this task easy Note: This function will call function #2 (when that function is available) to handle the task of converting the number of days, O hours, 0 minutes, and 0 seconds to a total number of seconds. When function #2 returns the converted time, this function can then return the resulting total number of seconds to the main function The main function should handle all user input and output display statements. The general structure of main is as follows: * * . Display a welcome to the user Prompt the user to select from a menu of choices, which correspond to the three task functions. Read in the user's answer and test to determine the user's choice of function. (A switch or if-else lf the user enters an invalid choice not available on the menu, an error message should be displayed. Based on the user's valid choice, prompt the user for data needed by the task function, and read in the data Call the appropriate task function to complete the task, passing the data read in. Display the answer returned from the task function, including text explaining what is being displayed. Test your program by selecting a different function each time. Also test with different input values to verify that your functions supply the correct arithmetic answers. Extra credit: Add a loop to repeat the menu as long as the user enters an invalid choice. * * * *

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

Beyond Big Data Using Social MDM To Drive Deep Customer Insight

Authors: Martin Oberhofer, Eberhard Hechler

1st Edition

0133509796, 9780133509793

More Books