Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Program 1 : List Menu operation Create a menu to allow the user to add, insert, remove, find the maximum, the minimum, and sort the

Program1: List Menu operation Create a menu to allow the user to add, insert, remove, find the maximum, the minimum, and sort the list in descending order (larger to smaller value). Declare your list as list of string.
studentFullName=["Mike navarro","Miguel saba","Maria Rami"]
You may use any of build in functions. Here is an sample output:
1- Add an item to the list
2- Remove an item from the list
3- Insert an item to the list
4- Find maximum
5- Find Minimum
6- Sort the list in descending order
7- Quit the program
Please enter your option: 3
Where do you want to insert the item? (Enter the index number)1
Please enter the value for the item you want to insert: "Tina Mari"
Your original List : ["Mike navarro","Miguel saba","Maria Rami"]
After inserting an item into index 1:
["Mike navarro","Tina Mari", "Miguel saba","Maria Rami"]
Once the user enters an option, your program should execute the code for that option and displays the list before and after the operations. Make sure to use a while loop so the program runs until user enters the quit option.
Program 2 BurstList:
Write a program to determine the length of bursts of zeros in a list of N numbers stored in a List. The program should record the length of the bursts of zeros in another List. The program should then print the lengths of the bursts.
Using this second List with the lengths of the bursts, it should also compute and print the following: the average length of the bursts, the minimum burst length, the maximum burst length, and the total number of zeros (the sum of the burst lengths).
Your program should:
1. Prompt the user for the size of the list (N). Then it should prompt the user to enter N numbers and store them into an list called burstList. Note, you should specify the maximum size of N allowed (based on how large you declare your List).
2. Given N and list, your program should compute the lengths of the bursts of zeros and store them in an list called BurstLengths. After computing and storing the burst lengths you should terminate your BurstLengths list with a sentinel (1). Use a for loop in this step.
3. Given the BurstLengths List with a sentinel (1), use a while loop to print the list of burst lengths. Format this nicely in a table with headings.
4. Given the BurstLengths List with a sentinel (1), compute and then print the following information:
a. Average burst length
b. Minimum burst length
c. Maximum burst length
d. Total number of zeros
Example data and results:
N (entered by the user and stored in N): 15
List of numbers (entered by the user and stored in list):
1,0,0,0,0,3,7,0,0,0,0,0,0,50,0
List of bursts (computed by your program and stored in BurstList): 4,6,1,1
Average burst length (computed by your program): 3.67
Minimum burst length (computed by your program): 1
Maximum burst length (computed by your program): 6
Total number of zeros (computed by your program): 11
Results:
Burst Length
14
26
31
Average burst length: 3.67
Minimum burst length: 1
Maximum burst length: 6
Total number of zeros: 11
Hints:
Check the boundaries (beginning and end of the lists). Test your program with a list of numbers that ends with a 0 and another that doesnt end with a 0 and make sure your program works properly. Similarly, test it with lists that start with a 0 and those that dont.
Use a flag variable (such as burst_open) to keep track of whether you are in the middle of a burst or not. When you encounter a burst (the first 0 in a burst) you can set the burst_open variable to 1. When you encounter the end of a burst, you can set the burst_open variable to 0.
Develop your program in parts. You can develop and test the code for the different steps separately.
Note that you can create your own BurstList to test if the code for steps 3 and 4 work
before completing step 2. In the end, you should have one program that contains all steps.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Visual Basic 6 Databases

Authors: Charles Williams

1st Edition

1861002025, 978-1861002020

More Books

Students also viewed these Databases questions