I would like to know how to add up the integers after the id number.
For instance:
12345 = id number
19
21
22
23
-1
54321
23
15
-1
my code so far is
Code:
#include<iostream>
#include<fstream>
//void AverageSpeed(double, double);
using namespace std;
const int sentinel = -1;
int main(){
int count;
int time;
int time1;
int time2;
int time3;
int time4;
ifstream input;
ofstream out;
int id;
double velocity;
int distance = 1;
double average;
double sum;
int timesum[4];
input.open("race1.dat");
out.open("raceresults.txt");
cout << "Vehicle Id Average Speed (Mph) Status" << endl;
cout << "*******************************************************" << endl;
out << "Vehicle Id Average Speed (Mph) Status" << endl;
out << "*******************************************************" << endl;
input >> id;
while (!input.eof())
{
cout << id << endl;
out << id << endl;
input >> time;
count = 0;
while (time != -1)
{
cout << time << endl;
count ++;
input >> time;
}
input >> id;
}
input.close();
out.close();
return 0;
}
/***********************************/
//void AverageSpeed(double velocity, double time)
//{
//velocity =
//average = time/4;