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:
#include <iostream> #include <fstream> using namespace std; int main() { const int NUM_ROWS = 3; const int NUM_COLS = 30; double forecast[NUM_ROWS][NUM_COLS]; double rainyDays = 0; int rows, cols; ifstream datafile; datafile.open("RainOrShine.dat"); if (!datafile) cout << "Error opening data file.\n"; else { cout << "Three-Month Analysis\n\n"; for(cols = 0; cols < NUM_COLS; cols++) { for(rows = 0; rows < NUM_ROWS; rows++) { } } }can someone please help me to go in the right direction? I really appreciate it
Your opening a file, but never reading from it. I assume you want to read in the data here:
{
cout << "Three-Month Analysis\n\n";
for(cols = 0; cols < NUM_COLS; cols++)
{
for(rows = 0; rows < NUM_ROWS; rows++)
{
// read in data?
}
}
}
HOW to read in the data will depend on how the input file is set up.