#include using namespace std; typedef double* dblDynPtr; int main() { int n_days
ID: 3629117 • Letter: #
Question
#include
using namespace std;
typedef double* dblDynPtr;
int main()
{
int n_days; //number of days the user will be observing
int n_observe=3; //number of observations
bool eighty = false;
double l_temp = 137;
double t_rain = 0;
double average = 0;
const double kona = 0.0;
cout << "How many days will you be analyzing? : "<< endl;
cin >> n_days;
//setup of the array
dblDynPtr *weather = new dblDynPtr[n_days]; //rows
for (int i = 0; i < n_days; i++)
{
weather[i] = new double [n_observe];
}
//input for dynamic array
cout <<"Enter the maximum, minimum, and precipitation for each day." < cout <<"And press enter after each entry of numbers." < for (int i=0; i < n_days; i++)
{
for (int j=0; j < n_observe; j++)
{
cin >> weather[i][j];
}
}
//
for (int i = 0; i < n_days; i++)
{
if (weather[i][0] == 80) // checking if it reaches 80
{
eighty = true;
}
if (weather[i][1] < l_temp) //checking to see the lowest temperature
{
l_temp=weather[1][1];
}
t_rain += weather[1][2];
}
if (eighty)
{
cout <<"The temperature has reached 80 degrees for at least once" << endl;
}
else
{
cout <<"The high temperature has never 80 degrees" << endl;
}
cout << "Total precipitation is: " << t_rain << " Average:" << average << static const double > (t_rain)/n_days << endl;
cout << "Low temperature is: " << l_temp << endl;
for (int i = 0; i < n_days; i++)
{
delete [] weather[1];
}
delete [] weather;
return 0;
}
Explanation / Answer
cout << "Total precipitation is: " << t_rain << " Average:" << average << static_cast <double> (t_rain)/n_days << endl;
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.