1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
morpeh [17]
3 years ago
8

You need to write a menu driven program. The program allows a user to enter five numbers and then asks the user to select a choi

ce from a menu. The menu should offer the following four options – 1. Display the smallest number entered 2. Display the largest number entered 3. Display the sum of the five numbers entered 4. Display the average of the five numbers entered
Computers and Technology
1 answer:
Jobisdone [24]3 years ago
3 0

Answer:

In Python:

nums = []

for i in range(5):

   num = int(input("Num: "))

   nums.append(num)

print("1 - Smallest")

print("2 - Largest")

print("3 - Sum")

print("4 - Average")

menu = int(input("Select menu: "))

if menu == 1:

   print("Smallest: ",min(nums))

elif menu == 2:

   print("Largest: ",max(nums))

elif menu == 3:

   isum = 0

   for i in range(5):

       isum+=nums[i]

   print("Sum: ",isum)

elif menu == 4:

   isum = 0

   for i in range(5):

       isum+=nums[i]

   print("Average: ",isum/5)

else:

   print("Invalid Menu Selected")

Explanation:

This program uses a list to get inputs for the 5 numbers

Here, the list is initialized

nums = []

This iterates from 1 to 5

for i in range(5):

This gets input for the 5 numbers

   num = int(input("Num: "))

This appends each number to the list

   nums.append(num)

The next 4 lines represents the menu

<em>print("1 - Smallest")</em>

<em>print("2 - Largest")</em>

<em>print("3 - Sum")</em>

<em>print("4 - Average")</em>

This prompts the user for menu

menu = int(input("Select menu: "))

If menu is 1, print the smallest

<em>if menu == 1:</em>

<em>    print("Smallest: ",min(nums))</em>

If menu is 2, print the largest

<em>elif menu == 2:</em>

<em>    print("Largest: ",max(nums))</em>

If menu is 3, calculate and print the sum of all inputs

<em>elif menu == 3:</em>

<em>    isum = 0</em>

<em>    for i in range(5):</em>

<em>        isum+=nums[i]</em>

<em>    print("Sum: ",isum)</em>

If menu is 4, calculate and print the average of all inputs

<em>elif menu == 4:</em>

<em>    isum = 0</em>

<em>    for i in range(5):</em>

<em>        isum+=nums[i]</em>

<em>    print("Average: ",isum/5)</em>

If menu is not 1 to 4, then print invalid menu

<em>else:</em>

<em>    print("Invalid Menu Selected")</em>

You might be interested in
Jorge, a sports statistician for soccer, has kept track of how many shots-on-goal each player on a team made in each game. This
kondaur [170]
The answer is A
Explanation it’s A
8 0
3 years ago
Think of an example in your life where a number could be described as data, information, and knowledge
zhannawk [14.2K]

Answer:

how many event you have been too in the last month (well non during this time but as an example)

Explanation:

4 0
3 years ago
Cations - Office 2016 A
Vika [28.1K]

Answer:

1345

Explanation:

6 0
3 years ago
Read 2 more answers
Police officers conducting traffic stops on minority drivers more than non-minority drivers is an example of what?
MAXImum [283]

Answer:

Cultural bias

Explanation:

Certain verifiable studies have been made across the United States of America on traffic stops, which revealed significant cases of cultural/racial bias. Black people were 20 percent more likely to be stopped and searched by the police than white people.  

Within a six-year period, starting from 2011, researchers studied over 100 million traffic stops cases which were carried out by twenty-one state patrol agencies.

7 0
3 years ago
How to write greater than or equal to in excel if function
natali 33 [55]

Answer:>=

Explanation:3>=4

I

5 0
3 years ago
Other questions:
  • What was the first<br> 1:search engine<br> 2:website<br> 3:time the internet started
    6·1 answer
  • What is a Software Quality Assurance Audit?
    12·1 answer
  • Which is the last step in conducting a URL search?
    6·1 answer
  • Write a program that uses an "if" statement to determine if the number is greater than one. If the number is greater than 1, the
    9·1 answer
  • Availability is an essential part of ________ security, and user behavior analysis and application analysis provide the data nee
    14·1 answer
  • Which of the following are screen objects used to maintain, view, and print data from a database
    9·1 answer
  • Read the following sentences: “The Soviet Union’s famous launch of a satellite called Sputnik had been an embarrassment for the
    12·1 answer
  • Which feature do we most likely use to quickly change the background, fonts, and layout?
    12·1 answer
  • When you are typing data that is in a series, such as days of the week or months of the year, you can use this tool to complete
    11·1 answer
  • What is the destination ip address when an ipv4 host sends a dhcpdiscover message?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!