problem the weather service bureau department has data representing monthly rainfall 5153483
Problem
The Weather Service Bureau department has data representing monthly rainfall for a year and we would like to create a table categorizing each month as rainy (rainfall 20% higher than average) dry (rainfall 25% lower than average) or average. The data file for monthly rainfall is called rainfall.txt (Links to an external site.)Links to an external site.. You need to down the file rainfall.txt and store it in the same folder of your lab5.cpp
Output
The year's average monthly rainfall was 139 mm.
September has the highest rainfall (190 mm).
January has the lowes rainfall (95 mm)
Month Rainfall(mm) Classification
——- ————— ————–
1 95 Dry
2 100 Dry
3 120 Average
4 130 Average
5 135 Average
6 145 Average
7 155 Average
8 185 Rainy
9 190 Rainy
10 160 Average
11 130 Average
12 120 Average
Program Requirements:
Implement the following functions in the program:
- void inputRainfall(int rainFal l[], int size)
The function reads the monthly rainfall from the file rainFall.txt and stores them in the array rainFall - int calculateAverageRainFall(int rainFall [], int size)
Return the average monthly rainfall - void classifyAndDisplayRainfall(int rainFall[], int months);
Classify and display each month as average, rainy, or dry.
Hints on lab assignment 5
#include
#include
#include
using namespace std;
const int NUM_MONTHS=12;
const double RAIN_RATE=0.20;//20% more rain than average
const double DRY_RATE = 0.25;
void inputRainFall(int [], int);
int calculateAverageRainFall(int [], int );
void classifyAndDisplayRainfall(int [],int);
int main()
{int rainFall[NUM_MONTHS];
//Read rainfall from the the file and the fill them in the array
//Calculate the average rainfall by calling the function calculateAverageRainFall and display the average rainfall
//Classify months as Dry, Average, or Rainy and display the result by calling the function classifyAndDisplayRainFall
}
Define the function inputRainFall
void inputRainFall(int rainFall[], int size)
{//See page on 277 on how to read numeric data from the file.
//The rainfall read from the file rainfall.txt and store them in the array rainFall.
}
int calculateAverageRainFall(int rainFall [], int size)
{
Note: Use the function ceil (double x) to round a number up. It returns the smallest integer greater than or equal to x.
return ceil(float(sum / 12));
}
void classifyAndDisplayRainfall(int rainFall[], int months)
{
//Use a one-dimensional array month to store string month
string month[] = {“January”, “February”, “March”, “April”, “May”, “June”, “July”, “August”, “September”, “October”, “November”, “December”};
//Call the function calculateAverageRainFall to get rainfall average
//Classify months as Dry, Average, or Rainy and display the result
//Use setw to align columns
}//end
note: use only c++
also for file rainfall.txt.
you can create a notepad and put these values inside the notepad and save it as rainfall.txt
95
100
120
130
135
145
155
185
190
160
130
120