I am unsure of how to fix this. I attached a picture of the feedback from the teacher. COSC 1336 – Programming Fundamentals I Program 9 – Functions, Lists, and Strings Write a program that read 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, and the name of the months with the highest and lowest amounts. The input data is available in Program9.txt file. No input, processing, or output should happen in the main function. All work should be delegated to other functions. The program should have at least 5 functions (main and developerInfo included). Include the recommended minimum documentation for each function. See the program one template for more details. Do not use any global variables. You will not get credit for the program if you do. Run your program with the input file, Program9.txt. Create a folder named, fullname_program9. Program9.txt input file information

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

I am unsure of how to fix this. I attached a picture of the feedback from the teacher.

COSC 1336 – Programming Fundamentals I Program 9 – Functions, Lists, and Strings

Write a program that read 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, and the name of the months with the highest and lowest amounts. The input data is available in Program9.txt file.

No input, processing, or output should happen in the main function. All work should be delegated to other functions. The program should have at least 5 functions (main and developerInfo included). Include the recommended minimum documentation for each function. See the program one template for more details.

Do not use any global variablesYou will not get credit for the program if you do.

Run your program with the input file, Program9.txt. Create a folder named, fullname_program9.

Program9.txt input file information

1.89

1.99

2.14

2.51

5.03

3.81

1.97

2.31

2.91

3.97

2.68

2.44

The code I have

# Main function

def main():

    developerInfo()

    # get rainfall info using getData function

    rainfall = pull_data()

    # get the total rainfall for year using totalRainfallOfTheYear function

    total_rainfall = total_rain_year(rainfall)

    # get the average monthly rainfall using averageMonthlyRainfall function

    avg = average_monthly_rain(rainfall)

    # print the total rainfall for the year

    print("Total rainfall for the year: ", float("{0:.2f}".format(total_rainfall)))

    # print the average monthly rainfall

    print("The average monthly rainfall is: ", float("{0:.2f}".format(avg)))

    # print the month with highest rainfall using highestRainfall function

    print("Month with highest rainfall is: " + highest_monthly_rain(rainfall))

    # print the month with lowest rainfall using lowestRainfall function

    print("Month with lowest rainfall is: " + lowest_rainfall(rainfall))

#Function that reads the rainfall data from

#the text file program9.txt

def pull_data():

    # open the text file

    inFile = open('program9.txt', 'r')

    #read the first record

    lineRead = inFile.readline()

    #while more records exsist

    while lineRead != '':

        # split records into substrings

        words = lineRead.split()

        # Read next record

        lineRead = inFile.readline()

    # close file

    inFile.close()

    return words

# This function returns the total yearly rainfall

def total_rain_year(rainfall):

    total = 0.0

    # iterate through the rainfall list

    for i in rainfall:

        # add each data to total

        total = total + (float)(i)

    # return the total rainfall

    return total

# This function calculates and returns the average monthly rainfall

def average_monthly_rain(rainfall):

    # get the total rainfall for the year

    total = total_rain_year(rainfall)

    # calculate and return the average rainfall

    avg = total / len(rainfall)

    return avg

# Function that returns the month with highest rainfall

def highest_monthly_rain(rainfall):

    # store the month names in a list

    months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]

    index = 0

    # assume the month 1 has the highest rainfall

    highest = rainfall[0]

    highest_index = index

    # iterate through the rainfall list

    while index < len(rainfall):

        # compare and get the index of the month with highest rainfall

        if(rainfall[index] > highest):

            highest_index = index

            highest = rainfall[index]

        index = index + 1

    # return the month name using the index of the month with highest rainfall

    return months[highest_index]

# Function that returns the month with lowest rainfall

def lowest_rainfall(rainfall):

    # store month names in a list

  months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]

    index = 0

    # assume month 1 has the lowest rainfall

    lowest = rainfall[0]

    lowest_index = index

    # iterate through the list

    while index < len(rainfall):

        # compare and get index of month with lowest rainfall

        if(rainfall[index] < lowest):

            lowest_index = index

            lowest = rainfall[index]

        index = index + 1

    # return month name using index of month with lowest rainfall

    return months[lowest_index]

    #End of the main function

# Call the main function

main()

#End of program 9

_______________________________________________________________________

This is the template that must be used in the code

def main():

inFile = open('program9.txt', 'r')

lineRead = inFile.readline()       # Read first record

    while lineRead != '':              # While there are more records

       words = lineRead.split()        # Split the records into substrings

       annualRainfall = float(words[0])

       print(format(annualRainfall, '.2f'))

          lineRead = inFile.readline()    # Read next record

       # Close the file.

    inFile.close() # Close file

  # Call the main function.

main()

 

 

The important requirement missing is:
No input, processing, or output should happen in the main function. All work should be delegated to other
functions.
The results are wrong.
Need to have IPO chart like this for each function.
T*****
# Function: developerInfo
#
# Description: Prints Programmer's information
# Parameters: None
# Returns:
Nothing
#
#*
*************
************
%23
Transcribed Image Text:The important requirement missing is: No input, processing, or output should happen in the main function. All work should be delegated to other functions. The results are wrong. Need to have IPO chart like this for each function. T***** # Function: developerInfo # # Description: Prints Programmer's information # Parameters: None # Returns: Nothing # #* ************* ************ %23
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
C-string
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education