Question: For this problem, can you make sure there is only one return(0) ( not multiple exits). This is what i have so far: #include #include

For this problem, can you make sure there is only one return(0) ( not multiple exits).

For this problem, can you make sure there is only one return(0)

This is what i have so far:

#include #include #include

using namespace std;

int main() { int attempts = 0;

double data;

string fName;

ifstream inFile;

ofstream outFile; //Gets input file from user do { cout > fName;

inFile.open(fName.c_str());

attempts ++;

if (!inFile.is_open()) cout

//Skips first two lines inFile.ignore( 100 , ' ' ); inFile.ignore( 100 , ' ' );

while(!inFile.eof()) { //Read each line of file inFile >> data; }

inFile.close(); return 0; }

Write a C++ program that will process a stream of GPS data. Each line of data starts with a command, followed by the data for that command. There will be one command per line. Your program should. 1. Ask the user for the name of a data file - echo print the file name 2. Open the data file 1. if the file fails to open, return to step 1 3. Skip the first two lines of the data file 4. Process each command in the data file 5. Report the following to both the screen (cout) and a file named GPS.report 1. Final Location 2. Total distance traveled (rounded to one decimal place) 3. Distance to starting point (rounded to one decimal place) Commands START - indicates the starting location of the trip STOP - indicates the ending location of the trip DATA -indicates a turning point. Assume 1. All coordinates are in a two dimension cartesian coordinate plane 2. All numerical output should be rounded to 1 decimal places Sample Input GPS Data File :Command x-coordinate y-coordinate START 0 0 DATA 24 24 DATA 4 24 DATA 4 124 DATA -25 12 DATA 00 STOP 195 215 Sample Output Please Enter The Name Of The Data File: data.txt : Final Location: (195.0, 215.0) Total distance traveled 587.6 : Distance to starting point 290.3

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!