Can anyone quickly verify?

Im getting several syntax errors starting on line 96 and up in regards to semicolons and brackets and I dont understand why.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
 /*
My Name
COP 2000
HW 4 Race Results
3/25/2018*/

#include <iostream>
#include <string>
#include <iomanip>
using namespace std;

//what will be used below with functions
void getRaceTimes(string &, double &);
void findWinner(string, string, string, double, double, double);
void welcome();
double raceAverage(double, double, double);
bool validate_user_input(double);

int main()
{
	//these are the vaiables
	string insert_racers_name, racers_name_1, racers_name_2, racers_name_3;
	double insert_racers_time, racers_time_1, racers_time_2, racers_time_3;
	return 0;
}

void welcome()
{
	//this displays the welcome prompt
	cout << "***********************************\n";
	cout << "Welcome to Race Results Program\n";
	cout << "You are Asked to Enter the Three Racer's Names\n";
	cout << "and Their Associated Race Time.\n\n";
	cout << "Please enther a real number for Race Time (the Race Time Must be > 0)";
	cout << "\n\nProgram Developed by: My Name :)\n";
	cout << "***********************************";
}

void getRaceTimes(string &insert_racers_name, double &insert_racers_time)
{
	cout << "Please enter the racer's first name > ";
	cin >> insert_racers_name;
	cout << "Please enter the racer's time >";
	cin >> insert_racers_time;

	while (insert_racers_time <= 0)
		cout << "Invalid. Please try again.";
	cin >> insert_racers_time;
}


void findWinner(string racers_name_1, string racers_name_2, string racers_name_3, double racers_time_1, double racers_time_2, double racers_time_3)

{
	//this will display after the names and times have been 
	if (racers_time_1 > racers_time_2 && racers_time_1 > racers_time_3)
	{
		cout << "Congratulations " << racers_name_1 << "!!! You are the winner!!\n";
		cout << "***** Your winning time is: " << racers_time_1 << " *****";
	}

	//
	else if (racers_time_2 > racers_time_1 && racers_time_2 > racers_time_3)
	{
		cout << "Congratulations " << racers_name_2 << "!!! You are the winner!!\n";
		cout << "***** Your winning time is: " << racers_time_2 << " *****";
	}

	else if (racers_time_3 > racers_time_1 && racers_time_3 > racers_time_2)
	{
		cout << "Congratulations " << racers_name_3 << "!!! You are the winner!!\n";
		cout << "***** Your winning time is: " << racers_time_3 << " *****";
	}

	//because these times tie, only displaying one of the times
	else if (racers_time_1 > racers_time_3 && racers_time_1 == racers_time_2)
	{
		cout << "We have a TIE, " << racers_name_1 << "and" << racers_name_2 << "!!\n";
		cout << "***** Your winning time is: " << racers_time_1 << " *****";
	}

	else if (racers_time_1 > racers_time_2 && racers_time_1 == racers_time_3)
	{
		cout << "We have a TIE, " << racers_name_1 << "and" << racers_name_3 << "!!\n";
		cout << "***** Your winning time is: " << racers_time_1 << " *****";
	}

	else if (racers_time_2 > racers_time_1 && racers_time_2 == racers_time_3)
	{
		cout << "We have a TIE, " << racers_name_2 << "and" << racers_name_3 << "!!\n";
		cout << "***** Your winning time is: " << racers_time_2 << " *****";
	}

	else (racers_time_1 == racers_time_2 && racers_time_2 == racers_time_3)
	{
		cout << "We have a 3 TIE!! No winner for this race...\n";

	}
}

double raceAverage(double racers_time_1, double racers_time_2, double racers_time_3)
{
	//this is gonna calculate the average of the racers times
	double raceAverage = (racers_time_1 + racers_time_2 + racers_time_3) / 3.0;
	cout << "Overall Race Time Average: " << raceAverage << "";

	return raceAverage;
}
Last edited on
peace of cake, this line is wrong

else (racers_time_1 == racers_time_2 && racers_time_2 == racers_time_3)

may not be the only problem, but start there.
Last edited on
I originally had it as an else if statement but for some reason I thought that was wrong. fixed it. everything compiles now, just getting some warnings about unreferenced local variables now. Thank you.
Now I dont know why the program doesnt actually display anything when I try to test it.
@newbstarter

Now I dont know why the program doesnt actually display anything when I try to test it.


I would say it's because you don't actually call ANY of the functions. You created string variables, period.
@whitenite1
AH youre right. I was so used to writing everything within the main I forgot that I had to call the functions. Im supposed to call all declared functions to the main, Im look in my book later to see if i can figure that out since i cant seem to find how to do that on google.
@newbstarter

Here's a small start. I changed your variables to be arrays, to make it easier. Right now, all the program does is display the welcome message, and lets you enter the 3 first names and 3 times. This should help you understand how to to pass the variables to functions.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;

//what will be used below with functions
void getRaceTimes(string insert_racers_name[3] , double insert_racers_time[3]); // Passed arrays don't need pointers.
void findWinner(string insert_racers_name[3], double insert_racers_time[3]);
void welcome();
double raceAverage(double, double, double);
bool validate_user_input(double);

int main()
{
	//these are the vaiables
	string insert_racers_name[3];
	double insert_racers_time[3];
	welcome();
	getRaceTimes(insert_racers_name, insert_racers_time);
	return 0;
}

void welcome()
{
	//this displays the welcome prompt
	cout << "***********************************\n";
	cout << "Welcome to Race Results Program\n";
	cout << "You are Asked to Enter the Three Racer's Names\n";
	cout << "and Their Associated Race Time.\n\n";
	cout << "Please enther a real number for Race Time (the Race Time Must be > 0)";
	cout << "\n\nProgram Developed by: My Name :)\n";
	cout << "***********************************\n\n";
}

void getRaceTimes(string insert_racers_name[3], double insert_racers_time[3])
{
	for(int x=0;x<3;x++)
	{
		cout << "Please enter the racer #" << x+1 << "'s, first name > ";
		cin >> insert_racers_name[x];
		cout << "Please enter the racer #" << x+1 <<"'s time >";
		cin >> insert_racers_time[x];

		while (insert_racers_time[x] <= 0)
		{
			cout << "Invalid. Please try again.";
			cin >> insert_racers_time[x];
		}
	}
}


void findWinner(string racers_name_1, string racers_name_2, string racers_name_3, double racers_time_1, double racers_time_2, double racers_time_3)

{
	//this will display after the names and times have been 
	if (racers_time_1 > racers_time_2 && racers_time_1 > racers_time_3)
	{
		cout << "Congratulations " << racers_name_1 << "!!! You are the winner!!\n";
		cout << "***** Your winning time is: " << racers_time_1 << " *****";
	}

	//
	else if (racers_time_2 > racers_time_1 && racers_time_2 > racers_time_3)
	{
		cout << "Congratulations " << racers_name_2 << "!!! You are the winner!!\n";
		cout << "***** Your winning time is: " << racers_time_2 << " *****";
	}

	else if (racers_time_3 > racers_time_1 && racers_time_3 > racers_time_2)
	{
		cout << "Congratulations " << racers_name_3 << "!!! You are the winner!!\n";
		cout << "***** Your winning time is: " << racers_time_3 << " *****";
	}

	//because these times tie, only displaying one of the times
	else if (racers_time_1 > racers_time_3 && racers_time_1 == racers_time_2)
	{
		cout << "We have a TIE, " << racers_name_1 << "and" << racers_name_2 << "!!\n";
		cout << "***** Your winning time is: " << racers_time_1 << " *****";
	}

	else if (racers_time_1 > racers_time_2 && racers_time_1 == racers_time_3)
	{
		cout << "We have a TIE, " << racers_name_1 << "and" << racers_name_3 << "!!\n";
		cout << "***** Your winning time is: " << racers_time_1 << " *****";
	}

	else if (racers_time_2 > racers_time_1 && racers_time_2 == racers_time_3)
	{
		cout << "We have a TIE, " << racers_name_2 << "and" << racers_name_3 << "!!\n";
		cout << "***** Your winning time is: " << racers_time_2 << " *****";
	}

	else
	{
		cout << "We have a 3 TIE!! No winner for this race...\n";

	}
}

double raceAverage(double racers_time_1, double racers_time_2, double racers_time_3)
{
	//this is gonna calculate the average of the racers times
	double raceAverage = (racers_time_1 + racers_time_2 + racers_time_3) / 3.0;
	cout << "Overall Race Time Average: " << raceAverage << "";

	return raceAverage;
}
Last edited on
I understand arrays a bit as I've done some reading on them but I have constraints and cant use them on this one. I've read my book again on calling functions and I think Im heading torwards the right direction now. Only problem is getting 3 uninitiliazed variable errors. Which seem to be the bane of my existence. Never understand why I get them. Line 27.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*
Name
COP 2000
HW 4 Race Results
3/25/2018*/

#include <iostream>
#include <string>
#include <iomanip>
using namespace std;

//what will be used below with functions
void getRaceTimes(string &, double &);
void findWinner(string, string, string, double, double, double);
void welcome();
double raceAverage(double, double, double);
bool validate_user_input(double);

int main()
{
	//these are the vaiables
	string insert_racers_name, racers_name_1, racers_name_2, racers_name_3;
	double insert_racers_time, racers_time_1, racers_time_2, racers_time_3;

	welcome();
	getRaceTimes(insert_racers_name, insert_racers_time);
	findWinner(racers_name_1, racers_name_2, racers_name_3, racers_time_1, racers_time_2, racers_time_3);
	raceAverage(racers_time_1, racers_time_2, racers_time_3);

	return 0;
}

void welcome()
{
	//this displays the welcome prompt
	cout << "***********************************\n";
	cout << "Welcome to Race Results Program\n";
	cout << "You are Asked to Enter the Three Racer's Names\n";
	cout << "and Their Associated Race Time.\n\n";
	cout << "Please enther a real number for Race Time (the Race Time Must be > 0)";
	cout << "\n\nProgram Developed by: Name :)\n";
	cout << "***********************************";
}

void getRaceTimes(string &insert_racers_name, double &insert_racers_time)
{
	cout << "Please enter the racer's first name > ";
	cin >> insert_racers_name;
	cout << "Please enter the racer's time >";
	cin >> insert_racers_time;

	while (insert_racers_time <= 0)
		cout << "Invalid. Please try again.";
	cin >> insert_racers_time;
}


void findWinner(string racers_name_1, string racers_name_2, string racers_name_3, double racers_time_1, double racers_time_2, double racers_time_3)

{
	//this will display after the names and times have been 
	if (racers_time_1 > racers_time_2 && racers_time_1 > racers_time_3)
	{
		cout << "Congratulations " << racers_name_1 << "!!! You are the winner!!\n";
		cout << "***** Your winning time is: " << racers_time_1 << " *****";
	}


	else if (racers_time_2 > racers_time_1 && racers_time_2 > racers_time_3)
	{
		cout << "Congratulations " << racers_name_2 << "!!! You are the winner!!\n";
		cout << "***** Your winning time is: " << racers_time_2 << " *****";
	}

	else if (racers_time_3 > racers_time_1 && racers_time_3 > racers_time_2)
	{
		cout << "Congratulations " << racers_name_3 << "!!! You are the winner!!\n";
		cout << "***** Your winning time is: " << racers_time_3 << " *****";
	}

	//because these times tie, only displaying one of the times//
	else if (racers_time_1 > racers_time_3 && racers_time_1 == racers_time_2)
	{
		cout << "We have a TIE, " << racers_name_1 << "and" << racers_name_2 << "!!\n";
		cout << "***** Your winning time is: " << racers_time_1 << " *****";
	}

	else if (racers_time_1 > racers_time_2 && racers_time_1 == racers_time_3)
	{
		cout << "We have a TIE, " << racers_name_1 << "and" << racers_name_3 << "!!\n";
		cout << "***** Your winning time is: " << racers_time_1 << " *****";
	}

	else if (racers_time_2 > racers_time_1 && racers_time_2 == racers_time_3)
	{
		cout << "We have a TIE, " << racers_name_2 << "and" << racers_name_3 << "!!\n";
		cout << "***** Your winning time is: " << racers_time_2 << " *****";
	}

	else if (racers_time_1 == racers_time_2 && racers_time_2 == racers_time_3)
	{
		cout << "We have a 3 TIE!! No winner for this race...\n";

	}
}

double raceAverage(double racers_time_1, double racers_time_2, double racers_time_3)
{
	//this is gonna calculate the average of the racers times//
	double raceAverage = (racers_time_1 + racers_time_2 + racers_time_3) / 3.0;
	cout << "Overall Race Time Average: " << raceAverage << "";

	system("pause");

	return raceAverage;
}
@newbstarter

You're getting the errors because they are uninitialized, and don't have any values. Since you cannot use arrays, here is the only way I can think of to assign values to the variables needed.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
int main()
{
	//these are the vaiables
	string insert_racers_name, racers_name_1, racers_name_2, racers_name_3;
	double insert_racers_time, racers_time_1, racers_time_2, racers_time_3;
	int x;
	welcome();
	for(x=0;x<3;x++)
	{
		getRaceTimes(insert_racers_name, insert_racers_time);
		if(x==0)
		{
			racers_name_1 = insert_racers_name;
			racers_time_1 = insert_racers_time;
		}
		else if(x==1)
		{
			racers_name_2 = insert_racers_name;
			racers_time_2 = insert_racers_time;
		}
		else if (x==2)
		{
			racers_name_3 = insert_racers_name;
			racers_time_3 = insert_racers_time;
		}
	}
	// Just to show the variables equal the inputs
	cout << racers_name_1 << " " << racers_time_1 << endl;
	cout << racers_name_2 << " " << racers_time_2 << endl;
	cout << racers_name_3 << " " << racers_time_3 << endl;

	findWinner(racers_name_1, racers_name_2, racers_name_3, racers_time_1, racers_time_2, racers_time_3);
	raceAverage(racers_time_1, racers_time_2, racers_time_3);

	return 0;
}


Got a question, though. Shouldn't a winner be the racer that finished in the SHORTEST time? That would mean, they drove the fastest, not the slowest.
Last edited on
@whitenite1

well that's a huge oversight on my part. Yeah the lowest time would be the fastest thus the winner. Also Im still learning to read and understand the language so its a bit difficult to follow your code. I have a basic understanding of it. I cant even get the if else/ else statements to trigger. Just skips directly to the very last one. I think Im just going to do nested if statements and see what happens.

current code: I change the variables names and have been attempting to debug it as I go along

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/*
Name
COP 2000
HW 4 Race Results
3/25/2018*/

#include <iostream>
#include <string>
#include <iomanip>
using namespace std;

//what will be used below with functions
void getRaceTimes(string &, double &);
void findWinner(string, string, string, double, double, double);
void welcome();
double raceAverage(double, double, double);
bool validate_user_input(double);

int main()
{
	//these are the variables
	string racerName, racer1, racer2, racer3;
	double raceTime, time1, time2, time3;

	welcome();
	getRaceTimes(racerName, raceTime);
	findWinner(racer1, racer2, racer3, time1 = 0, time2 = 0, time3 = 0);
	raceAverage(time1, time2, time3);

	return 0;
}

void welcome()
{
	//this displays the welcome prompt
	cout << "***********************************\n";
	cout << "Welcome to Race Results Program\n";
	cout << "You are Asked to Enter the Three Racer's Names\n";
	cout << "and Their Associated Race Time.\n\n";
	cout << "Please enther a real number for Race Time (the Race Time Must be > 0)";
	cout << "\n\nProgram Developed by: Name :)\n";
	cout << "***********************************\n";
}

void getRaceTimes(string &racerName, double &raceTime)
{
	
		cout << "Please enter the racer's first name > ";
		cin >> racerName;
		cout << "Please enter the racer's time >";
		cin >> raceTime;
		cout << "Please enter the racer's second name > ";
		cin >> racerName;
		cout << "Please enter the racer's time >";
		cin >> raceTime;
		cout << "Please enter the racer's third name > ";
		cin >> racerName;
		cout << "Please enter the racer's time >";
		cin >> raceTime;
	while (raceTime <= 0)
		cout << "Invalid. Please try again.";
	cin >> raceTime;
}


void findWinner(string racer1, string racer2, string racer3, double time1, double time2, double time3)
{
	//this will display after the names and times have been 
	if ((time1 < time2) && (time1 < time3))
	{
		cout << "Congratulations " << racer1 << "!!! You are the winner!!\n";
		cout << "***** Your winning time is: " << time1 << " *****";
	}


	else if ((time2 < time1) && (time2 < time3))
	{
		cout << "Congratulations " << racer2 << "!!! You are the winner!!\n";
		cout << "***** Your winning time is: " << time2 << " *****";
	}

	else if ((time3 < time1) && (time3 < time2))
	{
		cout << "Congratulations " << racer3 << "!!! You are the winner!!\n";
		cout << "***** Your winning time is: " << time3 << " *****";
	}

	//because these times tie, only displaying one of the times//
	else if ((time1 < time3) && (time1 == time2))
	{
		cout << "We have a TIE, " << racer1 << "and" << racer2 << "!!\n";
		cout << "***** Your winning time is: " << time1 << " *****";
	}

	else if ((time1 < time2) && (time1 == time3))
	{
		cout << "We have a TIE, " << racer1 << "and" << racer3 << "!!\n";
		cout << "***** Your winning time is: " << time1 << " *****";
	}

	else if ((time2 < time1) && (time2 == time3))
	{
		cout << "We have a TIE, " << racer2 << "and" << racer3 << "!!\n";
		cout << "***** Your winning time is: " << time2 << " *****";
	}

	else if ((time1 == time2 && time2 == time3))
	{
		cout << "We have a 3 TIE!! No winner for this race...\n";

	}
}

double raceAverage(double time1, double time2, double time3)
{
	//this is gonna calculate the average of the racers times//
	double raceAverage = (time1 + time2 + time3) / 3.0;
	cout << "Overall Race Time Average: " << raceAverage << "";

	

	return raceAverage;
}
Okay so this has been bugging me since I first started this so Ill ask, but shouldnt the variables for
void getRaceTimes(string &racerName, double &raceTime)
and
void findWinner(string racer1, string racer2, string racer3, double time1, double time2, double time3)
be named the same? I have a feeling that's why the winner isn't being being announced. it just cuts to the average being displayed but still gives me 0 for the amount.

also I know those nested if arent the cleanest way to do this but Im trying to get this fully working. and as I said if else statements seem to give me trouble.
current:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/*

COP 2000
HW 4 Race Results
3/25/2018*/

#include <iostream>
#include <string>
#include <iomanip>
using namespace std;

//what will be used below with functions
void getRaceTimes(string &, double &);
void findWinner(string, string, string, double, double, double);
void welcome();
double raceAverage(double, double, double);
bool validate_user_input(double);

int main()
{
	//these are the variables
	string racerName, racer1, racer2, racer3;
	double raceTime, time1, time2, time3;

	welcome();
	getRaceTimes(racerName, raceTime);
	findWinner(racer1, racer2, racer3, time1 = 0, time2 = 0, time3 = 0);
	raceAverage(time1, time2, time3);

	return 0;
}

void welcome()
{
	//this displays the welcome prompt
	cout << "***********************************\n";
	cout << "Welcome to Race Results Program\n";
	cout << "You are Asked to Enter the Three Racer's Names\n";
	cout << "and Their Associated Race Time.\n\n";
	cout << "Please enther a real number for Race Time (the Race Time Must be > 0)";
	cout << "\n\nProgram Developed by: :)\n";
	cout << "***********************************\n";
}

void getRaceTimes(string &racerName, double &raceTime)
{
	
		cout << "Please enter the racer's first name > ";
		cin >> racerName;
		cout << "Please enter the racer's time >";
		cin >> raceTime;
		cout << "Please enter the racer's second name > ";
		cin >> racerName;
		cout << "Please enter the racer's time >";
		cin >> raceTime;
		cout << "Please enter the racer's third name > ";
		cin >> racerName;
		cout << "Please enter the racer's time >";
		cin >> raceTime;
	while (raceTime <= 0)
		cout << "Invalid. Please try again.";
	cin >> raceTime;
}


void findWinner(string racer1, string racer2, string racer3, double time1, double time2, double time3)
{
	//this will display after the names and times have been 
	if ((time1 < time2) && (time1 < time3))
	{
		cout << "Congratulations " << racer1 << "!!! You are the winner!!\n";
		cout << "***** Your winning time is: " << time1 << " *****";


		if ((time2 < time1) && (time2 < time3))
		{
			cout << "Congratulations " << racer2 << "!!! You are the winner!!\n";
			cout << "***** Your winning time is: " << time2 << " *****";


			if ((time3 < time1) && (time3 < time2))
			{
				cout << "Congratulations " << racer3 << "!!! You are the winner!!\n";
				cout << "***** Your winning time is: " << time3 << " *****";


				//because these times tie, only displaying one of the times//
				if ((time1 < time3) && (time1 == time2))
				{
					cout << "We have a TIE, " << racer1 << "and" << racer2 << "!!\n";
					cout << "***** Your winning time is: " << time1 << " *****";


					if ((time1 < time2) && (time1 == time3))
					{
						cout << "We have a TIE, " << racer1 << "and" << racer3 << "!!\n";
						cout << "***** Your winning time is: " << time1 << " *****";
						{

							if ((time2 < time1) && (time2 == time3))
							{
								cout << "We have a TIE, " << racer2 << "and" << racer3 << "!!\n";
								cout << "***** Your winning time is: " << time2 << " *****";


								if ((time1 == time2 && time2 == time3))
								{
									cout << "We have a 3 TIE!! No winner for this race...\n";
								}
							}
						}
					}
				}
			}
		}
	}
}

double raceAverage(double time1, double time2, double time3)
{
	//this is gonna calculate the average of the racers times//
	double raceAverage = (time1 + time2 + time3) / 3.0;
	cout << "Overall Race Time Average: " << raceAverage << "\n";

	

	return raceAverage;
}
Last edited on
Your getRaceTimes ... is like:
1
2
3
4
int foo;
foo = 7;
foo = 42; // what happens to 7 here?
// what is the value of foo now? 


Your main() could have:
1
2
3
  getRaceTimes( racer1, time1 );
  getRaceTimes( racer2, time2 );
  getRaceTimes( racer3, time3 );

but that obviously requires that the function asks less.
1
2
while (raceTime <= 0)
		cout << "Invalid. Please try again.";


This demonstrates a massive misunderstanding of loops. If raceTime is less than zero, this will loop forever. Forever. There will be no trying again. The output will be:

Invalid. Please try again.Invalid. Please try again.Invalid. Please try again.Invalid. Please try again.Invalid. Please try again.Invalid. Please try again.Invalid. Please try again.Invalid. Please try again.Invalid. Please try again.Invalid. Please try again.Invalid. Please try again.Invalid. Please try again.Invalid. Please try again.Invalid. Please try again.Invalid. Please try again.Invalid. Please try again.Invalid. Please try again.Invalid. Please try again.Invalid. Please try again.Invalid. Please try again.Invalid. Please try again.Invalid. Please try again.Invalid. Please try again.Invalid. Please try again.Invalid. Please try again.Invalid. Please try again.Invalid. Please try again.Invalid. Please try again.Invalid. Please try again.Invalid. Please try again.Invalid. Please try again.Invalid. Please try again.Invalid. Please try again.Invalid. Please try again.Invalid. Please try again.Invalid. Please try again.Invalid. Please try again.Invalid. Please try again.Invalid. Please try again.Invalid. Please try again.Invalid. Please try again.Invalid. Please try again.Invalid. Please try again.Invalid. Please try again.Invalid. Please try again.Invalid. Please try again.Invalid. Please try again.Invalid. Please try again.Invalid. Please try again.... forever
Topic archived. No new replies allowed.