Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions

Question

WHAT IS ACCOUNTING AND FUNCTIONS?

Answered: 1 week ago

Question

Breathing explain?

Answered: 1 week ago

Question

WHAT IS DOUBLE ENTRY ACCOUNTING SYSTEM?

Answered: 1 week ago