Computer Science – BASIC / PYTHON language
Write program with functions and Arrays to implement the following.
Miles Driven Application using Arrays and Functions.
Create two arrays
Monthname$(12) This array contains month names such as “January”, “February”, etc
MilesDriven(12) ‘ This array contains the miles driven for the month.
Notice that the MonthNames$(12) array is a string array while MilesDriven(12) is numeric array.
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 MonthName with Largest Miles
Type E to exit.
· If the user types P.
Populate all the arrays.
· 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.
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.