Answered step by step
Verified Expert Solution
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 IO:
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 reprompt 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 and inclusive. It must display an error message if the user enters a value outside this range and reprompt for a valid value. See the sample program for the exact text of the prompt and any error messages
displayLMStateelapsedTime 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 LMs altitude;
a float representing the LMs 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
IO 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 and inclusive. It must display an error message if the user enters a value outside this range and reprompt for a valid value. The function must return the lesser of the userentered 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 messages
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 and meters per second, inclusive.
Print the second message if the final velocity is between and meters per second, exclusive
Print the third message if the final velocity is 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 when calling this function in Part ;
an int representing the current rate of fuel usage
The function calculates and returns the acceleration using the formula
acceleration gravitational constant rate of fuel consumption
updateAltitudealtitude 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 altitude velocity
Remember, however, that the surface of the moon stubbornly limits the altitude to nonnegative values, and your code must do the same.
updateVelocityvelocity 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:
updateFuelfuel 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 fuel rate of fuel consumption
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started