Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

We want to track weather conditions during the past year\'s three-month summer s

ID: 3674855 • Letter: W

Question

We want to track weather conditions during the past year's three-month summer season as has designated each day as either rainy ('R'), cloudy ('C'), or sunny ('S').

Write a program that stores this information in s 3x30 array of characters, where the row indicates the month and the column indicates the day of the month. Note no data is being captured for the 31st of any month.

This program will read the data in from a file called RainOrShine.txt. From this data it you should create a report that displays , for each month and for the whole three month period, how many days were rainy, how many were cloudy, and how many were sunny. It should also report which of the months had the largest number of rainy days.

The rain or shine text has the following information:

R C R S R S R R S R S C R C S S S S R S C S R C S S C C R S
C R R R S R S R C S R C R S S S R S C R R S C C S C S C R R
C R C C S C C R R R S S S C R C C C R C R S S S R S C R R C

The output should look like this:

Explanation / Answer

Hi, I have written the required program in python, as no specific programming language was mentioned.

And yes the last line of the question doesn't make sense. I don't understand how did you want the output to look like. So, this program produces the output which I think will make sense. ;)

Following is the python program.

def main():   

    #read the data from file into an array
    array = []
    for line in open('E:WorkCheggQ&AQ58_Rainy_PythonRainOrShine.txt').readlines():
        array.append(line.split(' '))
      
    lnrd = 0 #largest no of rainy days
    lnrd_month = 1 #month with largest no of rainy days
  
    for i in range(len(array)):
        nRainyDays = 0
        nCloudyDays = 0
        nSunnyDays = 0
      
        for j in range(len(array[i])):
            if (array[i][j] == 'R'):
                nRainyDays = nRainyDays + 1
            elif (array[i][j] == 'C'):
                nCloudyDays = nCloudyDays + 1
            else:
                nSunnyDays = nSunnyDays + 1
              
        print "Month No. : ", i+1
        print "No. of Rainy Days: ", nRainyDays
        print "No. of Cloudy Days: ", nCloudyDays
        print "No. of Sunny Days: ", nSunnyDays
        print
      
        if(lnrd < nRainyDays):
            lnrd = nRainyDays
            lnrd_month = i + 1;
  
    print "Largest no. of rainy days are in month no: ", lnrd_month
  
main()

Please thumbs up the answer if you find it useful.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote