Question
Basic Python Program HELP NEEDED! I have tried numerous times to create a function that allows me to call-back both the largest miles driven and
Basic Python Program HELP NEEDED! I have tried numerous times to create a function that allows me to call-back both the largest miles driven and the smallest miles driven; however, my program breaks off or goes blank when I run it. Can someone help me with the Largest Miles & Smallest miles function?
WHAT IS EXPECTED:
Write program with functions and Arrays to implement the following.
Miles Driven Application using Arrays and Functions.
Create two arrays
Monthname This array contains month names such as January, February, etc.
MilesDriven This array contains the miles driven for the month. It should be of size
Write a program to display the menu with the following options and ask for the user input.
Type P to populate miles and month name.
Type S to search for Month.
Type M to search for Month name with smallest Miles
Type L to search for Month Name with Largest Miles
Type E to exit.
If the user types P.
Populate all the arrays. Collect 12 month names and miles driven for each month.
If the user types S then:
Ask the user for the Month Name.
Search the array for that Month Name and find its position in the Monthname array.
Display the MonthName, and MilesDriven at the position found during the above search.
If the user types M then:
Search the array for the smallest miles in MilesDriven array and find its position.
Display the MonthName, and MilesDriven at the position found during the above search.
If the user types L then:
Search the array for the largest Miles in MilesDriven array and find its position.
Display the MonthName, and MilesDriven at the position found during the above search.
If the user types E. then:
Terminate the program after displaying the message shown in the test case scenario below.
If the user types any other option:
Display the message Invalid Choice. Try again and go back and display the menu.
PS: You program must keep displaying the menu until the user types the option E, to exit the program.
For exact input and output messages, please refer to the test case scenario.
TEST Scenario:
**** MENU OPTIONS **** Type P to populate miles and month name. Type S to search for Month Type M to search for Month name with smallest Miles Type L to search for Month Name with Largest Miles Type E to exit Please enter your choice: 'P' Please enter a month name: 'JAN' Please enter miles driven for the month: 120 Please enter a month name: 'FEB' Please enter miles driven for the month: 234 Please enter a month name: 'MARCH' Please enter miles driven for the month: 542 Please enter a month name: 'APRIL' Please enter miles driven for the month: 743 Please enter a month name: 'MAY' Please enter miles driven for the month: 283 Please enter a month name: 'JUNE' Please enter miles driven for the month: 999 Please enter a month name: 'JULY' Please enter miles driven for the month: 731 Please enter a month name: 'AUG' Please enter miles driven for the month: 777 Please enter a month name: 'SEPT' Please enter miles driven for the month: 826 Please enter a month name: 'OCT' Please enter miles driven for the month: 932 Please enter a month name: 'NOV' Please enter miles driven for the month: 22 Please enter a month name: 'DEC' Please enter miles driven for the month: 958 **** MENU OPTIONS **** Type P to populate miles and month name. Type S to search for Month Type M to search for Month name with smallest Miles Type L to search for Month Name with Largest Miles Type E to exit Please enter your choice: 'S' Please enter the month name to search: 'JAN' The month name is: JAN and the miles driven for the month is: 120 **** MENU OPTIONS **** Type P to populate miles and month name. Type S to search for Month Type M to search for Month name with smallest Miles Type L to search for Month Name with Largest Miles Type E to exit Please enter your choice: 'S' Please enter the month name to search: 'OCT' The month name is: OCT and the miles driven for the month is: 932 **** MENU OPTIONS **** Type P to populate miles and month name. Type S to search for Month Type M to search for Month name with smallest Miles Type L to search for Month Name with Largest Miles Type E to exit Please enter your choice: 'M' The result for searching the smallest miles: The month name is: NOV and the miles driven for the month is: 22 **** MENU OPTIONS **** Type P to populate miles and month name. Type S to search for Month Type M to search for Month name with smallest Miles Type L to search for Month Name with Largest Miles Type E to exit Please enter your choice: 'L' The result for searching the largest miles: The month name is: JUNE and the miles driven for the month is: 999 **** MENU OPTIONS **** Type P to populate miles and month name. Type S to search for Month Type M to search for Month name with smallest Miles Type L to search for Month Name with Largest Miles Type E to exit Please enter your choice: 'A' Invalid choice. Please try again! **** MENU OPTIONS **** Type P to populate miles and month name. Type S to search for Month Type M to search for Month name with smallest Miles Type L to search for Month Name with Largest Miles Type E to exit Please enter your choice: 'S' Please enter the month name to search: 'FFF' The month name not found! **** MENU OPTIONS **** Type P to populate miles and month name. Type S to search for Month Type M to search for Month name with smallest Miles Type L to search for Month Name with Largest Miles Type E to exit Please enter your choice: 'E' Thank you for using the program. Bye
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