Question

In: Computer Science

Design a program that lets the user enter the total rainfall for each of 12 months...

Design a program that lets the user enter the total rainfall for each of 12 months into an array. The program should calculate and display the total rainfall for the year, the average monthly rainfall, and the months with the highest and lowest amounts.

Design a program to solve Chapter 8 Programming Exercise 3 (Rainfall Statistics) in your textbook. Create parallel arrays for the month names and rainfall amounts for each month. Use month names (i.e. January, February, March, etc.) when printing out the months with the highest and lowest amounts. Include a modular (no global variables or constants) approach that includes and uses (at least) a main module and the following functions:
• GetLargestRainfall  takes parameters of the array of rainfall statistics and the size of the array. Returns the index of the array element with the largest rainfall
• GetSmallestRainfall  takes parameters of the array of rainfall statistics and the size of the array. Returns the index of the array element with the smallest rainfall

1- create IPO chart for GetLargestRainfall funcation and GetSmallestRainfall function.

2- create the properly aligned textbook fromat pseudocode.

3- Create the python source code, that represent the pseudocode requirements.

Solutions

Expert Solution

def GetLargestRainfall(rainfall,size):
    maxfall=rainfall[0]
    for i in range(size):
        if(rainfall[i]>maxfall):
            maxfall=rainfall[i]
    for i in range(size):
        if(rainfall[i]==maxfall):
            break
    return str(i)+" "+str(maxfall)

def GetSmallestRainfall(rainfall,size):
    minfall=rainfall[0]
    for i in range(size):
        if(rainfall[i]<minfall):
            minfall=rainfall[i]
    for i in range(size):
        if(rainfall[i]==minfall):
            break
    return str(i)+" "+str(minfall)

def main():
    rainfall=[]
    for i in range(12):
        a=float(input())
        rainfall.append(a)

    sum=0.0
    for i in rainfall:
        sum+=i
    avg=sum/12
    monthName=['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
    for i, j in zip(monthName, rainfall):
        print(i,j)
    print("Average monthly rainfall: ",avg)
    print("Smallest rainfal: ",GetSmallestRainfall(rainfall,12))
    print("Largest rainfall: ",GetLargestRainfall(rainfall,12))



if __name__ == "__main__":
    main()

I have attached the source code with output.

Working is simple as asked in the question.
Input Output are same as asked in the question.

For IPO chart and pseudo code I would advise you to do it, as I have already attached the source code and ouput respectively.
Apart from these things, I suggest you to run this program once for better understanding.

I hope it helps.


Related Solutions

Design a program that lets the user enter the total rainfall for each of 12 months...
Design a program that lets the user enter the total rainfall for each of 12 months into an array. The program should calculate and display the total rainfall for the year, the average monthly rainfall, and the months with the highest and lowest amounts. Requirements You must use the given function prototypes. You can add more functions if you like. def get_total_rainfall(months, months_len): def get_average_monthly_rainfall(months, months_len): def get_month_with_highest_rainfall(months, months_len): def get_month_with_lowest_rainfall(months, months_len): Design Considerations Use a global parallel array of...
Design a program that lets the user enter the total rainfall for each of 12 months...
Design a program that lets the user enter the total rainfall for each of 12 months into a list. The program should calculate and display the total rainfall for the year, the average monthly rainfall, the months with the highest and lowest amounts. This is my Pthon 3.8.5 code so far: #Determine Rainfall Program for a 12 month Period #It should calculate and output the "total yearly rainfall, avg monthly rainfall, the months with highest and lowest amounts #list of...
design a program that lets the user enter the total rainfall for each of 12 months...
design a program that lets the user enter the total rainfall for each of 12 months into an array. The program should calculate and display the total rainfall for the year, the average monthly rainfall, and the months with the highest and lowest amounts.   ---->>> Enhance the program so it sorts the array in ascending order and displays the values it contains. You can choose which sorting algorithm to use (bubble sort, selection sort, or insertion sort). Depending on your...
In Python: Design a program that lets the user enter the total rainfall for each of...
In Python: Design a program that lets the user enter the total rainfall for each of the 12 months into a list. The program should calculate and display the total rainfall for the year, the average monthly rainfall, the months with the highest and lowest amounts. However, to start, do not ask the user for input. Instead, hard code the monthly rainfalls as a list in your program, and then use the list to determine how to conduct the processing...
In python please design a program that lets the user enter the total rainfall for each...
In python please design a program that lets the user enter the total rainfall for each of the last 10 years into an array. The program should calculate and display the total rainfall for the decade, the average yearly rainfall, and the years with the highest and lowest amounts. Should have Indentation Comments Good Variables initializations Good questions asking for the parameters of the code Output display with explanation Screenshot
Write a C++ program that lets the user enter the total rainfall for each of 12...
Write a C++ program that lets the user enter the total rainfall for each of 12 months (starting with January) into an array of doubles. The program should calculate and display (in this order): the total rainfall for the year,     the average monthly rainfall,     and the months with the highest and lowest amounts. Months should be expressed as English names for months in the Gregorian calendar, i.e.: January, February, March, April, May, June, July, August, September, October, November,...
DESIGN A FLOWCHART IN FLOWGORITHM Rainfall Statistics Design a program that lets the user enter the...
DESIGN A FLOWCHART IN FLOWGORITHM Rainfall Statistics Design a program that lets the user enter the total rainfall for each of 12 months into an array. The program should calculate and display the total rainfall for the year, the average monthly rainfall , and the months with the highest and lowest amounts. PLEASE AND THANK YOU
How to write a C++ program that lets the user enter a string and checks if...
How to write a C++ program that lets the user enter a string and checks if it is an accepted polynomial. Accepted polynomials need to have one term per degree, no parentheses, spaces ignored.
Program on Visual Basic, VBA Create an application that lets the user enter a number of...
Program on Visual Basic, VBA Create an application that lets the user enter a number of seconds and produces output according to the following criteria: There are 60 seconds in a minute. If the number of seconds entered by the user is greater than or equal to 60, the program should display the number of minutes in that many seconds. There are 3,600 seconds in an hour. If the number of seconds entered by the user is greater than or...
C++ Write a program that lets the user enter a two letters which are f and...
C++ Write a program that lets the user enter a two letters which are f and s with a length of 5. And outputs how many times it was occurred and lists the 2 most repeating pattern with 5lengths of f and s. The output display should always start at three-f(s) .Include an option where user can retry the program. Example: Input: sssfsfsfssssfffsfsssssfffsffffsfsfssffffsfsfsfssssfffffsffffffffffffssssssssfffsffffsssfsfsfsfssssfffsssfsfsffffffssssssffffsssfsfsfsss Output: The most repeating 5lengths of pattern is: fffsf and occurred 6times. Output2: The second most repeating...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT