Question
Your task is to write 2 functions and some program code outside the functions. One of your functions is called position: and one is called
Your task is to write 2 functions and some program code outside the functions. One of your functions is called position: and one is called awards. Your program code will ask the race administrator to input the number of racers. It then checks to make sure that the number is valid (between 1 and 20 inclusive). Your program uses a for loop in order to make use of two nested functions: awards and position. Your program invokes the awards function and passes a function named position to it. The awards functions job is to print out a message for each racer after it obtains the finish position for the racer from the function called position. The position functions job is to prompt the judge to enter the finish position of a racer. The function then determines if the finish position is valid. To be valid, the position needs to be between 1 and n, where n is the parameter passed to the function by the program code. If the position entered is valid, the function will return its value to the awards function. If the position is not a valid number, the function will prompt the user to enter a valid number. Once a valid position number is returned to the awards function, the awards functions job is to print Congratulations, you have won Gold if the racer came in first. It will print Congratulations, you have won Silver if the racer came in second, and Congratulations, you have won Bronze if the racer came in third. For all other entrants, it will print Thank you for participating in raising money for this worthy cause. Show your program logic is correct by running the program several times to show that it recognizes an invalid number of racers and also correctly processes position numbers 1,2,3,4.
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