Create a class named WeatherReport that holds a daily weather report with data m
ID: 3566219 • Letter: C
Question
Create a class named WeatherReport that holds a daily weather report with data members such as dayOfMonth, highTemp, lowTemp, amountRain, and amountSnow. The constructor initializes the fields with default values: 99 for dayOfMonth, -9999 for highTemp, 9999 for lowTemp, and 0 for amountRain and amountSnow. Include a function that sets values for each field so that you can override the default values. Instantiate 30 WeatherReport objects and, in a loop, read the data from a file for a month's data. At the end of the month, a month-end WeatherReport object is created. Initialize the object with default values; then use a friend function to store the high temperature, low temperature, and rain and snow totals for the month in the object. The friend function takes two WeatherReport objects-the summary object and one day's object-and it returns an updated summary object. If the day's high temperature is higher than the summary object's high, then replace the summary high. If the day's low temperature is lower than the summary object's low, then replace the summary low. Accumulate rain and snow in the summary object. Write a main()function that creates a month-end weather report from the 30 daily reports. Save the file as NameProject4.cpp.Explanation / Answer
Code :
#include<stdio.h>
#include<conio.h>
#include<iostream.h>
class weather
{
int day,month;
float ltemp,htemp;
float rain_amt,snow_amt;
public:
weather();
void getdetail(int);
void putdetail();
};
weather :: weather()
{
day = 99;
ltemp = -999;
htemp = 999;
rain_amt = 0;
snow_amt = 0;
}
void getdata(int *m1,int *d1)
{
cout<<
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.