Hi everyone I hope you guys could give me a hand with this project, I am not an expert of c++ and i am really struggling with this.
here is the problem:
I been asked to make a programn as follows: A new railway journey planner is required to help users determine which of multiple published routes can be completed in a time period specified by the user.
I been also given a txt document with the data that is as follows + format:
Journey One
1 //number of changes (meaning that there would be two trains)
200 90 // first number is the distance and the second is the speed (Distance/speed = time)
100 60
Journey Two
0
300 120
Journey Three
2
50 50
50 75
100 60
the application has to calculate the total journey time for each journey and then compare it with the time period specified by the user. If the journey can be completed in the specified time then the result must be written to the screen and to an output text file called results.txt. If the journey cannot be completed in time then the results must be written to the screen only. Messages to the screen must indicate whether the journey is suitable or not.
*So first the user has to be able to input the time period in minutes or hours (thats one problem)
*then my biggest problem right now is making the data to be read properly, i should be using loops for this but i dont know how to do it... then it has to do the calculation to get the total time for each journey and then compare it to the others + user's
if you guys could help me with anything i would be much apreciated.
here is my code so far but its a propper fail....
#include "stdafx.h"
#include <fstream>
#include <iostream>
#include <tchar.h>
#include <string>
#include <cmath>
#include <iomanip>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
string JourneyName;
int TimeRequested;
int NumberOfChanges;
int DistanceLenght;
int DistanceSpeed;
int TimeRequiered;
ifstream inFile;
inFile.open ("JourneyData.txt", ios::in);
cout << "Please enter an approximate time you wish your journet to take: ";
cin >> TimeRequested;
inFile >> JourneyName;
getline(inFile, JourneyName);
inFile >> NumberOfChanges >> DistanceLenght;
inFile.ignore (1,' ');
inFile >> DistanceSpeed;
TimeRequiered = (DistanceLenght / DistanceSpeed);
inFile.close();
system ("pause");
return 0;
}