Question: Task: There should be one string input and two double inputs. How would you seperate all the strings in the line into one string and

Task: There should be one string input and two double inputs.

How would you seperate all the strings in the line into one string and all the of doubles into their respected fields.

I have got it to work however it does not take the input of the first double that it encounters.

This is an example of the input

Task: There should be one string input and two double inputs. How

This is what it outputs

would you seperate all the strings in the line into one string

Expected Output

Monticello => Monticello, 36.8297222, -84.8491667 Lexingtonlo => Lexingtonlo, 37.9886111, -84.4777778 Paducah => Paducah, 37.0833333, -88.6000000

Source Code:

//Code to handle double strings in input while (getline(cin,line)) { if (line.empty()) continue; istringstream is(line); string word; double num; while (is >> word) { cout > num; cout 0){ latitude = num; } else{ longitude = num; } } else { name += word; } }

// Duplicate Handler - name only right now if (!cities.count(name)){ cities.insert(make_pair(name, new City(name, latitude, longitude))); } name = ""; }

Monticello 36.8297222 -84.8491667 Lexington to 37.9886111 -84.4777778 Paducah 37.0833333 -88.6000000

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!