Create a variable named dayTempsCHI and assign to it a vecto

Create a variable named dayTemps_CHI and assign to it a vector whose elements are the following daily temperatures (in degree F) recorded for Chicago in the month of August. [75 79 86 86 79 81 73 89 91 86 81 82 86 88 89 90 82 84 81 79 73 69 73 79 82 72 66 71 69 66 66] Create a variable named dayTemps_SF and assign to it a vector whose elements are the following daily temperatures (in degree F) recorded for San Francisco in the month of August. [69 68 70 73 72 71 69 76 85 87 74 84 76 68 79 75 68 68 73 72 79 68 68 69 71 70 89 95 90 66 69] Determine how many days San Francisco\'s temperature was above average. Compute how many days Chicago\'s temperature was in the range [62 degree F, 78 degree F]. Compute how many days San Francisco\'s temperature was cooler than 72 degree F OR warmer than 80 degree F. Compute how many days Chicago\'s temperature was NOT between 70 degree F and 90 degree F, inclusive. Compute how many days San Francisco\'s temperature was NOT colder than 73 degree F AND NOT warmer than 89 degree F. Compute Chicago\'s temperatures that are warmer than 84 degree F but cooler than 90 degree F. Compute San Francisco\'s temperatures that are warmer than 65 degree F, cooler than 72 degree F, but NOT 69 degree F. Compute on which day(s) San Francisco\'s temperature was warmer OR the same as the temperature in Chicago? Compute on which day(s) the temperature was the same in both cities.

Solution

#include<iostream>
#include<vector>
using namespace std;

int main(){
float chi[] = {75,79,86,86,79,81,73,89,91,86,81,82,86,88,89,90,82,84,81,79,73,69,73,79,82,72,66,71,69,66,66};
float sf[]={69,68,70,73,72,71,69,76,85,87,74,84,76,68,79,75,68,68,73,72,79,68,68,69,71,70,95,89,90,66,69};
vector<float> dayTemp_CHI(chi, chi + sizeof(chi) / sizeof(float) );
vector<float> dayTemp_SF(sf, sf + sizeof(sf) / sizeof(float) );

//above avg temp
float avg_sf=0;
int count=0;
for (vector<float>::iterator it = dayTemp_SF.begin(); it != dayTemp_SF.end(); ++it){
avg_sf+=*it;
}
avg_sf /=dayTemp_SF.size();

for (vector<float>::iterator it = dayTemp_SF.begin(); it != dayTemp_SF.end(); ++it)
if(avg_sf<*it){
count++;
}
cout<<count<<endl;

//chicago 62 to 78
count =0;
for (vector<float>::iterator it = dayTemp_CHI.begin(); it != dayTemp_CHI.end(); ++it)
if(*it>=62 && *it<=78){
count++;
}

cout<<count<<endl;

return 0;}

 Create a variable named dayTemps_CHI and assign to it a vector whose elements are the following daily temperatures (in degree F) recorded for Chicago in the mo

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site