# Allison Obourn
# CS 115, Autumn 2021
# Lecture 29

# This program prompts the user for high temperatures until the user
# enters the word "done". It then computes and prints the number of
# those days that were above average and prints that out.

# NOTE: this program would be better if its tasks were divided into
#       functions. We will do this in a later lecture. 

def main():
    print("Type a temperature or \"done\" to finish")
    
    # an empty list to add temperatures to
    temperatures = []
    sum_temps = 0
    # get the first temperature before the loop so we have something
    # to compare with done
    temp = input("Day 1's high temp: ")
    count = 2
    while temp != "done":
        temp = int(temp)
        count = count + 1
        sum_temps = sum_temps + temp
        temperatures.append(temp) # add to our list
        # prompt again at the very end so that the next thing we will do is
        # our loop test. This way we stop right away once we get "done"
        temp = input("Day " + str(count) + "'s high temp: ")

    # compute average
    print()
    average = sum_temps / (count + 1)
    print("Average temp = " + str(average))

    # count up days above average
    count = 0
    for temp in temperatures:
        if temp > average:
            count = count + 1
    print(str(count) + " days were above average.")


main()
