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 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
//David Scheip
//Created 4.19.13
//Page 426 Number 3
//Write a program that creates three Weather_station objects.
//At each weather station, the wind speed, temperature and humidity are recorded.
//Use a constructor to initialize the values.
//Print out the data.
#include <iostream>
using namespace std;
class Weather_station
{
private:
int wind_speed;
double temp, humid;
public:
Weather_station(int, double, double);
void set_data();
void print_data();
};
Weather_station::Weather_station (int wind_speed_var, double temp_var, double humid_var)
:wind_speed (wind_speed_var), temp (temp_var), humid (humid_var)
{
cout << "enter wind speed, temp and humid";
cin >> wind_speed_var >> temp_var >> humid_var;
};
void Weather_station::print_data()
{
cout << "The Wind Speed is (mph) " << wind_speed << ", the Temperature is (°F) " << temp << endl <<" and the Humidity is (%) "<< humid << endl << endl;
};
int main()
{
int wind_speed_var;
double temp_var, humid_var;
Weather_station station1 (15, 32.2, 56.43), station2 (15, 32.2, 56.43), station3 (15, 32.2, 56.43);
station1.print_data();
station2.print_data();
station3.print_data();
cin.get();
};
|