I am supposed to be working on this problem that stores info in a 2x20 array of characters where the row indicates the month and the column indicates teh day. We have to read in from a file and then create a report that displays for each month and for the whole 2 month period..how many days were rainy, cloudy, and sunny. It also has to report which month had the largest num of rainy days...here's what i have so far:
I am supposed to be working on this problem that stores info in a 2x20 array of characters where the row indicates the month and the column indicates teh day. We have to read in from a file and then create a report that displays for each month and for the whole 2 month period..how many days were rainy, cloudy, and sunny. It also has to report which month had the largest num of rainy days...here's what i have so far:
int main()
{
const int NUM_MONTHS = 3;
const int NUM_DAYS = 30;
const int NUM_TYPES= 3;
char forecast[NUM_MONTHS][NUM_DAYS];
int counts [NUM_MONTHS][NUM_TYPES];
int rainyDays = 0;
ifstream datafile;
datafile.open("RainOrShine.txt");
if (!datafile)
cout << "Error opening data file.\n";
else
{
// Read data and load arrary
for(int month = 0; month < NUM_MONTHS; month++)
{
for(int day = 0; day < NUM_DAYS; day++)
{
datafile >> forecast[month][day];
}
datafile.ignore();
}
for(int month = 0; month < NUM_MONTHS; month++)
{
for(int day = 0; day < NUM_DAYS; day++)
{
cout << forecast[month][day] << '\t';
}
cout << endl;
}
// intialize counts arrarys to 0
for(int month = 0; month < NUM_MONTHS; month++)
{
for(int type = 0; type < NUM_TYPES; type++)
{
counts[month][type] =0;
}
}
// count all data
for(int month = 0; month < NUM_MONTHS; month++)
{
for(int day = 0; day < NUM_DAYS; day++)
{
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.