definition: Design and write a program that will store the rainfall for each of 12 months. The program should then calculate:
– the total rainfall for the year;
– the average rainfall for the year;
– the month with the most rain;
– the month with the least rain.
A. Problem Analysis – Following the directions in the assignment, clearly write up your problem analysis in this section.
This program will have multiple elements that needs to be fulfilled starting with how are we going to get the amount of rainfall data. For this first issue we will ask the user for their input and store it in a 2-diamentinal array (first part will be for the month second part will be for rainfall). This array will be one of the most important aspects of our program simply because it will hold the most important information in it and it will be called in all of our functions. My idea is to use multiple functions with our main array and use “for loops” to calculate all of our desired information. We are going to need a total of four functions to get our average rainfall, total rainfall, highest rainfall month and lowest rainfall month as well
 
Finally, we will display all our information for our users to see. Since this is a basic program in the future it could be built out to a web interface with dynamic updating information on cities weather patterns. That would be a great idea for college students studying meteorology, there could be many uses for a program like this.
Next, we will set up our functions and variables for our calculations I will outline them all below:
First I will have our users input information to build our 2-diamentional array month_data[12,2] (Month and rainfall) this array will be used in the following function to calculate average, total, highest and lowest rainfall.
Functions will be (NOTE: I am using the same variable names for all the functions since they will be declared inside of each of their own functions they will be local to that specific function. This way we will not be writing over existing information!):
– Average_Rain
· This will be the function that calculates average rain results
· It will have the array month_data[12,2] and variables count (used to help calculate our average by holding the data that calculated adding up all 12 months rainfall), the number 12 (second aspect to work our average out), ave_month and x (our placeholder)
· We will use a for loop to execute our results and the calculation of amount of rainfall per month (integer of 12) added up and the divided by 12 ( count / 12 = ave_month)
· Our expected output will be a written statement displaying the month and average rainfall
– Total_rain
· This will be the function that calculates total rain results
· It will have the array month_data[12,2] and variables in it counter, total_month and x for our placeholder
· We will use a for loop to execute our results and the calculation of each months results added up all together
· Our expected output will be a written statement displaying month and the total rainfall
– Less_rain
· This will be the function that calculates the month with the least rain
· It will have the array month_data[12,2] and variables counter, less_month and x for our placeholder
· We will use a for loop to execute our results, we will have to sort our array from lowest to highest then give our first value from the array (less_month[0])
· Our expected output will be a written statement displaying the month with the least rainfall
– Most_rain
· This will be the function that calculates the month with the most rain.
· It will have the array month_data[12,2] and variables counter, most_month and x for our placeholder
· We will use a for loop to execute our results; again we will have to sort our array and this time we will use the last result because it will be the largest (most_month[11])
· Our expected output will be a written statement displaying month with the highest the highest rainfall
“96% of our customers have reported a 90% and above score. You might want to place an order with us.”



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *