Problem with Nested Loops

I have an assignment where I have to write a program that uses nested loops to collect datat and calculate the average rainfall over a period of years. The program should first input the number of years. The outer loop will iterate once for each year. the inner loop will iterate twelve times, once for each month. Each iteration of the inner loop will input the inches of rainfall for that month.
My loops are pretty good to start with, but I just cant get the inches of rainfall to be present on output.
Can someone please point me in the right direction?

This is what I have so far:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
 inrain.open("inrain.txt");    // open input text
 outrain.open("outrain.txt");  // open output text

 for(outerLoop = 1; outerLoop <= 3; outerLoop++)
 {
  for(innerLoop = 1; innerLoop <= 12; innerLoop++)
  {
  //inner inner loop statements
   outrain << fixed << endl;
   outrain << "Month " << innerLoop << " =" << endl;
  }
 //outer loop statements
 outrain << fixed << endl;
 outrain << "Year " << outerLoop << endl;
 }
inrain.close();
outrain.close();


Both the outer loop and inner loop are outputting from outrain.txt. You open and close inrain.txt, but are doing nothing else with it.
Last edited on
Topic archived. No new replies allowed.