I've been working on this for a while now, and I haven't made much progress. I know I'm doing something wrong (hence the lack of code), so any critiques would mean a lot.
PROMPT:
Write a program that reads the date, the maximum high temperature, and the minimum low temperature for that date from a file. There is data for each of the 31 days in December. The program shall find and report: the highest temperature in the month, the date of the highest temperature, the lowest temperature in the month, and the date of the lowest temperature. In addition, the program shall find and report the average high and average low for the month. The output shall be written to a file. See below for an example of the output and how to format the output.
Output shall appear as follows:
http://gyazo.com/e49bdd2e6ab6ff6cc61cd179ffb97464
Use the following data for Dec. 1950 as your test data:
http://gyazo.com/5f0031a24fecd8f081a86c51b8f4412f
Weather Data from Station No. 3116952, Charlotte, NC December, 1950
Date Max Min Date Max Min
01 61 33 17 48 31
02 64 49 18 35 22
03 63 55 19 35 18
04 50 35 20 40 28
05 49 32 21 38 24
06 51 35 22 43 26
07 59 35 23 60 29
08 49 34 24 63 37
09 40 35 25 55 35
10 40 31 26 65 42
11 41 27 27 47 26
12 40 28 28 29 23
13 42 25 29 36 29
14 40 31 30 40 34
15 42 29 31 52 33
16 49 27
Anything you can offer is worthwhile! Thank you for your time.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;
int main()
{
double date, max, min;
ofstream outfile;
outfile.open("text.out");
ifstream infile;
infile.open("text.dat");
outfile << setw(32) << "Your Name" << endl
<< setw(32) << "Date" << endl << endl
<< setw(45) << "High and low temperatures reported for" << endl
<< setw(40) << "Charlotte, NC December, 1950" << endl << endl << endl;
outfile << "Day" << setw(14) << "Highest" << setw(20) << "Day" << setw(14) << "Lowest" << endl << endl;
infile >> date >> max >> min;
outfile.close();
infile.close();
return 0;
}
|