Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write these functions in Python: Functions that do I / O: showWelcome ( ) Display the welcome message. See the sample program for the exact

Write these functions in Python: Functions that do I/O:
showWelcome ()
Display the welcome message. See the sample program for the exact text.
getFuel ()
This function has no parameters and a return type of int. This function must prompt a user for positive integer value and return it. It must display an error message if the user enters a negative or zero value and re-prompt for a valid value. See the sample program for the exact text of the prompt and error message.
getAltitude()
This function must prompt a user for a real value between 1 and 9999, inclusive. It must display an error message if the user enters a value outside this range and re-prompt for a valid value. See the sample program for the exact text of the prompt and any error message(s).
displayLMState(elapsedTime, altitude, velocity, fuelAmount, fuelRate)
This function must display the state of the LM as indicated by the parameters. The parameters are:
an int representing the elapsed time the LM has been flown;
a float representing the LM's altitude;
a float representing the LM's velocity;
an int representing the amount of fuel on the LM;
an int representing the current rate of fuel usage.
See the sample program for the exact text and format of the display.
getFuelRate (currentFuel)
I/O - The parameter is an int representing the current amount of fuel in the LM. The function prompts the user for an integer value and makes sure it is between 0 and 9, inclusive. It must display an error message if the user enters a value outside this range and re-prompt for a valid value. The function must return the lesser of the user-entered value or the amount of fuel remaining on the LM (value passed in as a parameter). The user cannot use more fuel than is left on the lunar lander! See the sample program for the exact text and formatting of the prompt and any error message(s).
displayLMLandingStatus (velocity)
This function, as its name implies, displays the status of the LM upon landing. There are three possible outputs depending of the velocity of the LM at landing, they are:
Status at landing - The eagle has landed!
Status at landing - Enjoy your oxygen while it lasts!
Status at landing - Ouch - that hurt!
Print the first message if the final velocity is between 0 and -1 meters per second, inclusive.
Print the second message if the final velocity is between -1 and -10 meters per second, exclusive
Print the third message if the final velocity is -10 meters per second
See the sample program for the exact text and formatting.
Functions that Calculate:
updateAcceleration (gravity, fuelRate)
The parameters are:
a float representing the gravitational constant for the moon (use a value of 1.62 when calling this function in Part 2);
an int representing the current rate of fuel usage
The function calculates and returns the acceleration using the formula
acceleration ?tpl= gravitational constant rate of fuel consumption (:?tpl5}
updateAltitude(altitude, velocity, acceleration)
The parameters are:
a float representing the current altitude;
a float representing the current velocity;
a float representing the current acceleration.
The function calculates and returns the new altitude based on the provided inputs and the formula
altitude ?tp1= altitude ?tp0+ velocity ?tp0+(accelerationtp12)
Remember, however, that the surface of the moon stubbornly limits the altitude to nonnegative values, and your code must do the same.
updateVelocity(velocity, acceleration)
The parameters are:
a float representing the current velocity;
a float representing the current acceleration.
The function calculates and returns the new velocity based on the provided inputs and the formula:
()tp1(()tp0)tp1
updateFuel(fuel, fuelRate)
The parameters are:
an int representing the current amount of fuel on the LM;
an int representing the current rate of fuel usage.
The function calculates the remaining fuel. Note: This is a trivial function as long as your getFuelRate function behaves correctly.
fuel ?tp1= fuel ?tp0- rate of fuel consumption ?tpl
image text in transcribed

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_2

Step: 3

blur-text-image_3

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

Statistical And Scientific Database Management International Working Conference Ssdbm Rome Italy June 21 23 1988 Proceedings Lncs 339

Authors: Maurizio Rafanelli ,John C. Klensin ,Per Svensson

1st Edition

354050575X, 978-3540505754

More Books

Students also viewed these Databases questions

Question

explain the concept of strategy formulation

Answered: 1 week ago