#include "stdafx.h" #include <iostream> #include <string> using namespace std; int _tmain(int argc, _TCHAR* argv[]) { struct weather { // string name; int rain; double high; double low; double avg; }; weather month[12]; // string monthName[12] = { "January", "Febuary", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}; int i; for (i = 0; i < 12; i++); { // cout << "Please enter the name of the Month: "; // cin >> month[i].name; cout << "Please enter the Rain Fall in inches: "; cin >> month[i].rain; cout << "Please give the Highest Temperature: "; cin >> month[i].high; if (month[i].high < -100 || month[i].high > 140) { cout << "Hang on it couldn't have been that cold/hot. Please enter a valid temp: "; cin >> month[i].high; } cout << "Please give the Lowest Temperature: "; cin >> month[i].low; if (month[i].high < -100 || month[i].high > 140) { cout << "Come on, it couldn't have been that cold/hot. Please enter a valid temp: "; cin >> month[i].low; } month[i].avg = 0; month[i].avg = (month[i].high + month[i].low) / 2; } for (i = 0; i < 12; i++) { //cout << monthName[i] << endl; // cout << month[i].name << endl; cout << "Month " << i << endl; cout << "Rainfall: " << month[i].rain << "in" << endl; cout << "High: " << month[i].high << "f" << endl; cout << "Low: " << month[i].low << "f" << endl; cout << "Average Temp: " << month[i].avg << "/n" << endl; } return 0; } |