Assignment help

Write your question here.
Ok so I have began my assignment my goal is to create a program that will allow me to enter 3 racer names and times and display if they had tied or who had won the race. I am not allowed to use array or vectors. Any help is much appreciated.
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
# include <iostream>
# include <string>
using namespace std;
//function prototyping
void getRaceTimes(string&, double&);
void findWinner(string, string, string, double, double, double);
void welcome();
double raceAverage(double, double, double);

int main()
{
	string name1, name2, name3;
	double time1, time2, time3;

	welcome();
	getRaceTimes(racerName, raceTime);
	findWinner(racer1, racer2, racer3, time1 = 0, time2 = 0, time3 = 0);
	raceAverage(time1, time2, time3);
	
	return 0;
}
//function definition
void getRaceTimes(string&racerName, double&racerTime)
{
cout >> "Please enter the 1st racer's name"
cin << name1
cout >> "Please enter the racer's time"
cin << time1
cout >> "Please enter the 2nd racer's name"
cin << name2
cout >> "Please enter the racer's time"
cin << time2
cout >> "Please enter the 3rd racer's name"
cin << name3
cout >> "Please enter the racer's time"
cin << time3
while (racerTime <= 0)
{
	cout << "Invalid time, please enter a valid time"
}
void findWinner(string racer1, string racer2, string racer3, double time1, double time2, double time3)
{

}
void welcome()
{
	cout << "*****************************************************************************\n";
	cout << "Welcome to Race Results Program\n";
	cout << "You are Asked to Enter the Three Racers Names and their Associated Race Time\n " << endl;
	cout << "Please enter a real number for the Race Time (the race time must be > 0)\n";
	cout << "Program Developed by: *****\n";
	cout << "******************************************************************************\n" << endl;

}
double raceAverage(double time1, double time2, double time3)
{
	double average = 0;
	//need to calculate average
	
	return average;
}

Edit: where I am currently at
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
# include <iostream>
# include <string>
using namespace std;
//function prototyping
void getRaceTimes(string&, double&);
void findWinner(string, string, string, double, double, double);
void welcome();
double raceAverage(double, double, double);

int main()
{
	string name1, name2, name3;
	double time1, time2, time3;

	welcome();
	getRaceTimes(name1, time1);
	getRaceTimes(name2, time2);
	getRaceTimes(name3, time3); 
	findWinner(name1, name2, name3, time1, time2, time3);
	double average = raceAverage(time1, time2, time3);
	cout << endl;
	cout << endl;
	cout << "Race time average is: " << average << endl;
	
	return 0;
}
//function definition
void getRaceTimes(string&racerName, double&racerTime)
{
cout >> "Please enter the 1st racer's name"
cin << name1
cout >> "Please enter the racer's time"
cin << time1
cout >> "Please enter the 2nd racer's name"
cin << name2
cout >> "Please enter the racer's time"
cin << time2
cout >> "Please enter the 3rd racer's name"
cin << name3
cout >> "Please enter the racer's time"
cin << time3
while (racerTime <= 0)
{
	cout << "Invalid time, please enter a valid time"
}
void findWinner(string racer1, string racer2, string racer3, double time1, double time2, double time3)
{
	while (time1&&time2&&time3 > 0)
	{
		void getRaceTimes();

		if (time1 > time2 && time1 > time3)
		{
			cout << "Racer one is the winner!";
		}
		else if (time2 > time1 && time2 > time3)
		{
			cout << "Racer two is the winner!";
		}
		else if (time3 > time1 && time3 > time2)
		{
			cout << "Racer three is the winner!";
		}
		else if (time1 == time2 > time3)
		{
			cout << "Racer 1 and 2 have tied";
		}
		else if (time1 == time3 > time2)
		{
			cout << "Racers 1 and 3 have tied!";
		}
		else if (time2 == time3 > time1)
		{
			cout << "Racers 2 and 3 have tied!";
		}
	}
void welcome()
{
	cout << "*****************************************************************************\n";
	cout << "Welcome to Race Results Program\n";
	cout << "You are Asked to Enter the Three Racers Names and their Associated Race Time\n " << endl;
	cout << "Please enter a real number for the Race Time (the race time must be > 0)\n";
	cout << "Program Developed by: SEND HELP\n";
	cout << "******************************************************************************\n" << endl;

}
double raceAverage(double time1, double time2, double time3)
{
	double average = (time1 + time2 + time3) / 3.0;
	cout << "Race time average is: " << raceAverage << "";
	
	return average;
}
Last edited on
Hello austin66887,

Your code has potential, but has many problems.

You should compile your program first and try to fix the errors before posting. You would find that there are several lines that are missing a ";" at the end. The function "getRaceTimes" is missing the closing "}". And you are sending the function two variables that you do not even use. The function call for "getRaceTimes" sends two parameters, but the function wants to enter all three names and times. The while loop has no real use where it is. If the function was written differently it would have a use, but still will need changed.

Something to work on while I get the program to run.

Hope that helps,

Andy
Thank you Andy! But I actually ended up finishing the code last night.
Hello austin66887,

Good to hear you got it working.

If you are finished green check the thread so everyone will know.

Andy
Topic archived. No new replies allowed.