Question

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

Q: 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.

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.

Note: Please answer all the question.

Note: single question with different parts, it just all the information.

Homework Answers

Answer #1

Code Snippet:

def GetSmallestRainfall(arr,n):
   lowest = arr[0]
   lowestIndex = -1
   for i in range(n):
       if arr[i] <= lowest: #Calculating lowest rainfall index
           lowest = arr[i]
           lowestIndex = i
   return lowestIndex


def GetLargestRainfall(arr,n):
   highest = arr[0]
   highestIndex = -1
   for i in range(n): #Calculating highest rainfall index
       if arr[i] >= highest:
           highest = arr[i]
           highestIndex = i
   return highestIndex

def totalRainfall(arr,n):
   total = 0
   for i in range(n):
       total += arr[i] #Calculating total

   return total

def averageMonthlyRainfall(arr,n):
   average = totalRainfall(arr,n)/n #average
   return average

if __name__ == '__main__':
   #Months List
   months = ['January', 'February', 'March', 'April', 'May', 'June', 'July','August', 'September', 'October', 'November', 'December']
   arr = []
   for i in range(12): #Iterating over 12 as there are 12 months
       arr.append(float(input('Enter the Rainfall for %s: ' %months[i])))
   n = len(arr) #Length of the array
   print("Total rainfall : %d" %(totalRainfall(arr,n))) #Calling functions
   print("Average Monthly Rainfall %.2f" %(averageMonthlyRainfall(arr,n)))
   index = GetLargestRainfall(arr,n)
   print("Largest Rainfall %s %.2f" %(months[index],arr[index]))
   index = GetSmallestRainfall(arr,n)
   print("Smallest Rainfall %s %.2f" %(months[index],arr[index]))

Code Snippet:

Output:

IPO Chart:

Input Processing Output
Monthly Rainfall for 12 months in an year.

Compute the Total Rainfall by adding all the monthly rainfalls.

Compute the Average Rainfall by calling the Total Rainfall function and dividing the returned value by the length of the array.

Compute the Maximum Rainfall by finding the maximum value of the array.

Compute the Minimum Rainfall by finding the minimum value of the array.

Total Rainfall across all the months.

Average Monthly Rainfall.

Maximum Rainfall of the 12 months stats.

Minimum Rainfall of the 12 months stats.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Phone number lookup Design a program that has two parallel arrays: a string array named people...
Phone number lookup Design a program that has two parallel arrays: a string array named people that is initialized with the names of seven of your friends, and a string array named phoneNumbers that is initialized with your friends phone numbers. The program should allow the user to enter a persons name (or part of a persons name). it should then search for that person in the people array. If the person is found, it should get that persons phjone...
Create a simple Java class for a Month object with the following requirements:  This program...
Create a simple Java class for a Month object with the following requirements:  This program will have a header block comment with your name, the course and section, as well as a brief description of what the class does.  All methods will have comments concerning their purpose, their inputs, and their outputs  One integer property: monthNumber (protected to only allow values 1-12). This is a numeric representation of the month (e.g. 1 represents January, 2 represents February,...
Build two arrays[ ] (Integer and String) and convert them to two ArrayLists and write two...
Build two arrays[ ] (Integer and String) and convert them to two ArrayLists and write two overloaded generic static search method to find the index locations of a specified value. One of the search methods applies to the array type while the other (overloaded) search method applies to the collection type. Implement the following generic linear search method and write a client program to display results: (Here is the header) public static <E extends Comparable<E>> int search(E[] list, E key)...
Using the model proposed by Lafley and Charan, analyze how Apigee was able to drive innovation....
Using the model proposed by Lafley and Charan, analyze how Apigee was able to drive innovation. case:    W17400 APIGEE: PEOPLE MANAGEMENT PRACTICES AND THE CHALLENGE OF GROWTH Ranjeet Nambudiri, S. Ramnarayan, and Catherine Xavier wrote this case solely to provide material for class discussion. The authors do not intend to illustrate either effective or ineffective handling of a managerial situation. The authors may have disguised certain names and other identifying information to protect confidentiality. This publication may not be...