Please have a look at the following code:
---------------------------------------------------------------------------------------------------------
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
void printMonth(int month);
void PrintaLine(int, char);
void SkipLines (int);
void indent (int);
// PRECONDITION: month holds an integer 1-12
// POSTCONDITION: the corresponding month (Jan, Feb, ..., Dec) has been
// printed to the standard output.
ifstream infile1("input1.txt");
ifstream infile2("input2.txt");
ofstream outfile("output.txt");
int main()
{
string month[12];
double rainfall[12]; //this year's rainfall for each month
double averages[12]; //average rainfalls for each month
int currentMonth; //what month is it? 1-based
//
// Get the average rainfall for each month, Jan-Dec
//
// Read the in put files 1 and 2
for (int i=0; i<12; i++)
{
infile1 >> month[i] >> rainfall[i];
}
for (int j=0; j<12; j++)
{
infile2 >> month[j] >> averages[j];
}
PrintaLine (65, ':');
indent(10);
outfile << "The table shows the month avge and the diff\n";
PrintaLine (65, ':');
SkipLines(3);
outfile << setw (20) << setiosflags (ios::left) << "Months"
<< setw(20) << "Actual" << setw(20) << "Average"
<< setiosflags(ios::right)
<< setw (10) << "Difference" << endl;
SkipLines(1);
for (int i=0; i<12; i++)
{
outfile << setw (20) << setiosflags (ios::left) << month[i]
<< setw(20) << rainfall[i] << setw(20) << averages[i]
<< setiosflags(ios::right)
<< setw (10) << rainfall[i] - averages [i] << endl;
}
SkipLines (2);
outfile << "Negative sign in the Difference shows the Actual Rainfall is below Average Rainfall\n";
}
void PrintaLine(int n, char c){
for (int i=1; i<=n; i++)
outfile << c;
outfile << endl;
}
void SkipLines (int n){
for (int i=1; i<=n; i++)
outfile << endl;
}
void indent (int n){
for (int i=1; i<=n; i++)
outfile << ' ';
}
-------------------------------------------------------------------------------------------------------
This displays the table of the monthly rainfall and the avg. monthly rainfall and the diff. to the file output.
Now I want to do the following:
INTERACTIVE DISPLAY.
All files have been closed, ask the user if they want to analyze the data. If they say yes, ask if they want to see it in tabular or graphic output form (refer to Display 7.8 for how to do this). Ask what data they want to see (average, actual, divergence of actual from average).
Please reply me ASAP as I due my assignment soon
---------------------------------------------------------------------------------------------------------
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
void printMonth(int month);
void PrintaLine(int, char);
void SkipLines (int);
void indent (int);
// PRECONDITION: month holds an integer 1-12
// POSTCONDITION: the corresponding month (Jan, Feb, ..., Dec) has been
// printed to the standard output.
ifstream infile1("input1.txt");
ifstream infile2("input2.txt");
ofstream outfile("output.txt");
int main()
{
string month[12];
double rainfall[12]; //this year's rainfall for each month
double averages[12]; //average rainfalls for each month
int currentMonth; //what month is it? 1-based
//
// Get the average rainfall for each month, Jan-Dec
//
// Read the in put files 1 and 2
for (int i=0; i<12; i++)
{
infile1 >> month[i] >> rainfall[i];
}
for (int j=0; j<12; j++)
{
infile2 >> month[j] >> averages[j];
}
PrintaLine (65, ':');
indent(10);
outfile << "The table shows the month avge and the diff\n";
PrintaLine (65, ':');
SkipLines(3);
outfile << setw (20) << setiosflags (ios::left) << "Months"
<< setw(20) << "Actual" << setw(20) << "Average"
<< setiosflags(ios::right)
<< setw (10) << "Difference" << endl;
SkipLines(1);
for (int i=0; i<12; i++)
{
outfile << setw (20) << setiosflags (ios::left) << month[i]
<< setw(20) << rainfall[i] << setw(20) << averages[i]
<< setiosflags(ios::right)
<< setw (10) << rainfall[i] - averages [i] << endl;
}
SkipLines (2);
outfile << "Negative sign in the Difference shows the Actual Rainfall is below Average Rainfall\n";
}
void PrintaLine(int n, char c){
for (int i=1; i<=n; i++)
outfile << c;
outfile << endl;
}
void SkipLines (int n){
for (int i=1; i<=n; i++)
outfile << endl;
}
void indent (int n){
for (int i=1; i<=n; i++)
outfile << ' ';
}
-------------------------------------------------------------------------------------------------------
This displays the table of the monthly rainfall and the avg. monthly rainfall and the diff. to the file output.
Now I want to do the following:
INTERACTIVE DISPLAY.
All files have been closed, ask the user if they want to analyze the data. If they say yes, ask if they want to see it in tabular or graphic output form (refer to Display 7.8 for how to do this). Ask what data they want to see (average, actual, divergence of actual from average).
Please reply me ASAP as I due my assignment soon