Question
Using the weather_station_five_column.txt file produced by problem two above: Determine the highest and lowest temperatures in the state for the entire month of March 2018.
Using the weather_station_five_column.txt file produced by problem two above:
- Determine the highest and lowest temperatures in the state for the entire month of March 2018.
Print out (to the screen) the station names with highest and lowest temperatures along with the high and low values. (Multiple stations may record the same values for high and low.)
CODE:
#include
#include
#include
#include
#include
#include
using namespace std;
void splitString (string str,string*vec, int&len)
{
len=0;
string temp=" ";
stringstream ss(str);
while(ss)
{
ss>>temp;
vec[len++]=temp;
}
}
int main()
{
string line;
float TMAX=0;
float TMIN=1000;
string maxtemp;
string mintemp;
string max;
string min;
string*fileContent;
string*vec=new string[50];
int len;
float temp;
ifstream input;
int count=0;
int totalContent=0;
input.open("Correct_time_format.txt");
if(!input)
{
cout<<"Unable to process"< return 1; } while(!input.eof()) { getline(input,line); count++; } totalContent=count-1; fileContent=new string[totalContent]; input.seekg(ios::beg); while(!input.eof()) { getline(input, line); string temp; count=0; while(getline(input,line)) { fileContent[count++]=line; splitString(line,vec,len); maxtemp=vec[len-3]; mintemp=vec[len-2]; cout< if(atof(mintemp.c_str()) TMIN=atof(mintemp.c_str());} if(atof(maxtemp.c_str())>TMAX){ TMAX=atof(maxtemp.c_str());} } } cout<<" Max temperature:"< for(int i=0;i { line=fileContent[i]; splitString(line,vec,len); temp=atof(vec[len-3].c_str()); if(temp==TMAX) { for(int j=0;j<(len-5);j++) cout< cout< } } cout<<" MIN Temperature:"< for(int i=0;i { line=fileContent[i]; splitString(line,vec,len); temp=atof(vec[len-2].c_str()); if(temp==TMIN) { for(int j=0;j<(len-5);j++) cout< cout< } } input.close(); } I run the code it is not show anything, could somebody to help? thank you very much
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started