I'm stuck and I don't know what to do I need help. I need help on how to do the nested for loops and how to get to data from the input file to display corresponding values. Can somebody help me please. Read the attached documents and see if you can please. Input file is also provided.
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
using namespace std;
int main()
{
//Declares variables to hold value entered by user
int number;
int value;
//Loop declaration
int year;
int month;
//Open File
ifstream inFile;
inFile.open("input 3.txt");
if (!inFile) // if file could not be opened
{
cout << "Input file was not found!" << endl;
return 1;
}
//Displays title
cout<<"This Program prints monthly and average rainfalls of the last 10 years."<<endl<<endl;
//Prompts the user to enter the input data, reads value from keyboard and stores it in corresponding value
cout<<"Please enter the number of months per year to be averaged: ";
cin>>number;
cout<<endl;
//Validates entry of months, if not valid waits for valid entry
while (number >= 1 && number <=12)
inFile >> value;
for (year = 0; year < 10; year++) //outer loop for rows/lines
{
for (number = month; month < 12; month++) //inner loop for columns/number per row
{
cout<<setw(10)<<right<<value;
}
}
}if (!(number >= 1 && number <=12))
{
system ("cls");
cout<<"This Program prints monthly and average rainfalls of the last 10 years."<<endl<<endl;
cout<<"Please enter the number of months per year to be averaged: ";
cin>>number;
cout<<endl;
}
//Close file
inFile.close();
return 0;
}