This is my code so far. The out put is , the data from the .dat file.
#include <iostream>
#include<fstream>
#include<string>
using namespace std;
int main()
{
char NUM_MONTHS = 3;
// string name[NUM_MONTHS] = {"June","July","August");
char NUM_DAYS = 30;
char rainorshine [NUM_MONTHS][NUM_DAYS];
int month ,count ;
ifstream datafile;
datafile.open("RainOrShine.dat");
if (!datafile)
cout<<"Error";
else
{
cout<<" This is the data for June, July, August. " << endl<<endl;
cout<< "MONTH 0 = JUNE,MONTH 1 = JULY, MONTH 2 = AUGUST"<< endl<<endl;
for(month = 0; month < NUM_MONTHS ; month++)
{ for (count =0; count < NUM_DAYS ; count++)
{
cout << " MONTH " <<(month)
<< ",DAY " << (count+1) << " : ";
datafile >> rainorshine[month][count];
cout << rainorshine[month][count] << endl;
}
cout<<endl;
}
}
The output is like this:
MONTH 0, DAY1 : S
......................... // MONTH 0 means JUNE.
.........................
.........................
MONTH 0, DAY 30 : C
MONTH 1, DAY1 : R
.........................
......................... //MONTH 1 means JULY
.........................
MONTH 1, DAY 30 : S
MONTH 2, DAY1 : S
.........................
......................... //MONTH 2 means AUGUST
.........................
MONTH 2, DAY 30 : C
From now what I need to find out is 1.how many rainy, cloudy, sunny days in each month and whole 3 month period?
2. which of the 3 months had the largest number of rainy days.