Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Suppose you have a portable weather station that can measure the following Tempe

ID: 3709663 • Letter: S

Question

Suppose you have a portable weather station that can measure the following Temperature (degrees Celsius) Wind Speed (miles per hour) Barometric Pressure (mm of mercury e.g. 30.5) Precipitation (hundredths of an inch e.g. 0.05) The weather station has a GPS unit that can be used to provide location data in the form o altitude (meters). It also records the date (MM DD YYYY) and time (HH MM SS) of each me Measurements are recorded hourly and combined into a daily file (24 measurements per da Design a hierarchical structure to record measurements from the weather station. Store the measurements (One day of data) using this Data File e. Using the data write functions that will compute and print to the screen the following inform 1·Location of the weather statida (latitude, longitude and altitude) 2. High Temperature for the day with date and time 3. Low temperature for the day with date and time 4. Maximum wind speed for the 24-hour period with date and time 5. Total precipitation for the 24-hour period with data You may pass the entire array of records to the functions or pass just one record at a time

Explanation / Answer

#include<iostream>
#include<fstream>
#include<sstream>

using namespace std;


void getHighTemperature(string date, string time[], double temp[], int count){
   double max = temp[0];
   int index = 0;
   for (int i = 0; i<count; i++){
      if (temp[i] > max){
         max = temp[i];
         index = i;
      }
   }
   cout << date << endl;
   cout << "Time:" << time[index] << endl;
   cout << "High Temperature : " << max << " degree celsius" << endl;
    

}

void getLowTemperature(string date, string time[], double temp[], int count){
   double min = temp[0];
   int index = 0;
   for (int i = 0; i<count; i++){
      if (temp[i] < min){
         min = temp[i];
         index = i;
      }
   }
   cout << date << endl;
   cout << "Time:" << time[index] << endl;
   cout << "Low Temperature : " << min << " degree celsius" << endl;
    

}


void getMaxWindSpeed(string date, string time[], double windSpeed[], int count){
   double max = windSpeed[0];
   int index = 0;
   for (int i = 0; i<count; i++){
      if (windSpeed[i] > max){
         max = windSpeed[i];
         index = i;
      }
   }
   cout << date << endl;
   cout << "Time:" << time[index] << endl;
   cout << "Maximum Wind Speed : " << max << endl;
    

}


void getTotalPercip(string date, double percip[], int count){
   double sum = 0;
  
   for (int i = 0; i<count; i++){
      sum = sum + percip[i];
   }
   cout << date << endl;
   cout << "Total Percipitation : " << sum << endl;
    

}

int main(){

   string date;
   string line;
   string location;
   string time[100];
   double temp[100];
   double windSpeed[100];
   double presure[100];
   double percip[100];
   ifstream fin("datafile.txt");

   if (!fin){
      cout << "Error opening file ";
      return 0;
   }
   getline(fin, line);
   getline(fin, date);
   getline(fin,location);
   getline(fin,line);
   int count = 0;
   cout << location << endl;
   while (getline(fin,line)){
      stringstream ss(line);
      ss >> time[count] >> temp[count] >> windSpeed[count] >> presure[count] >> percip[100];
      count++;
   }
  
   getHighTemperature(date, time, temp,count);
   getLowTemperature(date, time, temp,count);
  
   getMaxWindSpeed(date,time,windSpeed,count);
   getTotalPercip(date,percip,count);
  
   
   return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote