Need assistance please

every time I try to build the solution it tells me there are several errors. I am using Visual Studio. Can anyone help please?
This is what I'm supposed to do
****
1.Storing the information of each car in an array (use multiple arrays if needed). Example: car numbers, colors of cars, lap time for each car, etc.
2.Validate user input via the following rules:

•Car number must be an integer
•Car color must be a string
•Lap time format must be MM:SS
1.Print out an error message if the user gives invalid input.
****

And here is what I have so far
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
#include<iostream>
#include<iomanip>
#include<string>
using namespace std;
using std::cout;
using std::endl;
using std::setprecision;
using std::string;

void printArray(string[], int);
void userInputArray(string array[], int size);
int userInputDriver(std::string[], int size);
int userInputCarColor(std::string[], int size);
int userInputTime(string array[], int size);

int main()
{
	//double carnumber[3];
	string driver_name[3];
	string CarColor[3];
	string Time[3];
	//double position[3];

	// string array
	string car1[3];
	string car2[3];
	string car3[3];
	string time1[3];
	string time2[3];
	string time3[3];
	string color1[3];
	string color2[3];
	string color3[3];

	userInputArray(car1, 3);
	userInputArray(car2, 3);
	userInputArray(car3, 3);
	userInputArray(time1, 3);
	userInputArray(time2, 3);
	userInputArray(time3, 3);
	userInputArray(color1, 3);
	userInputArray(color2, 3);
	userInputArray(color3, 3);
	printArray(car1, 3);
	printArray(car2, 3);
	printArray(car3, 3);
}
void printArray(string array[], int size)
{
	for (int i = 0; i < size; i++)
	{
		cout << array[i] << endl;
	}
}
void userInputArray(string array[], int size)
{
	cout << "Choose a carnumber ?" << endl;
	cin >> array[0];

	cout << "Choose a carcolor ?" << endl;
	cin >> array[1];

	cout << "Choose a laptime ?" << endl;
	cin >> array[2];
}
int userInputDriver(std::string[], int size)
{
	return 0;
}
int userInputCarColor(std::string[], int size)
{
	return 0;
}
int userInputTime(string array[], int size)
{
	return 0;
}
if (time1 < time2 && time1 < time3);		//check if car1 came in first
{
	if (time1 < time2)			//if yes, check where car2 and car3 placed
	{
		cout << car1 << color1 << " came in first with a score of " << time1 << endl;
		cout << car2 << color2 << " came in seconf with a score of " << time2 << endl;
		cout << car3 << color3 << " came in third with a score of " << time3 << endl;
	}
	else
	{
		cout << car1 << color1 << " came in first with a score of " << time1 << endl;
		cout << car3 << color3 << " came in second with a score of " << time3 << endl;
		cout << car2 << color2 << " came in third with a score of " << time2 << endl;
	}
}

if (time2 < time1 && time2 < time3)		// check if car2 came first
{
	if (time1 < time3)		//if yes, check where car1 and car3 placed
	{
		cout << car2 << color2 << " came in first with a score of " << time2 << endl;
		cout << car1 << color1 << " came in second with a score of " << time1 << endl;
		cout << car3 << color3 << " came in third with a score of " << time3 << endl;
	}
	else car2
	{
		cout << car2 << color2 << " came in first with a score of " << time3 << endl;
	cout << car1 << color1 << " came in second with a score of " << time1 << endl;
	cout << car2 << color2 << " came in third with a score of " << time2 << endl;

	return 0;
	}
}
}
system("pause");

void myfunc()
{
	cout << " Thanks for playing My Car Race" << endl;
}

Last edited on
every time I try to build the solution it tells me there are several errors


What and where are the errors? You should include them verbatim - copy and paste from the compiler output.
Severity Code Description Project File Line Suppression State
Error (active) expected a declaration Project1 c:\Users\Stephanie\Documents\Visual Studio 2015\Projects\Project1\Project1\Source.cpp 100
Error (active) expected a declaration Project1 c:\Users\Stephanie\Documents\Visual Studio 2015\Projects\Project1\Project1\Source.cpp 84
Error (active) expected a declaration Project1 c:\Users\Stephanie\Documents\Visual Studio 2015\Projects\Project1\Project1\Source.cpp 85
Error C2059 syntax error: 'if' Project1 c:\users\stephanie\documents\visual studio 2015\projects\project1\project1\source.cpp 84
Error C2447 '{': missing function header (old-style formal list?) Project1 c:\users\stephanie\documents\visual studio 2015\projects\project1\project1\source.cpp 85
Error C2059 syntax error: 'if' Project1 c:\users\stephanie\documents\visual studio 2015\projects\project1\project1\source.cpp 100
Error C2143 syntax error: missing ';' before '{' Project1 c:\users\stephanie\documents\visual studio 2015\projects\project1\project1\source.cpp 101
Error C2447 '{': missing function header (old-style formal list?) Project1 c:\users\stephanie\documents\visual studio 2015\projects\project1\project1\source.cpp 101
Error C2059 syntax error: '}' Project1 c:\users\stephanie\documents\visual studio 2015\projects\project1\project1\source.cpp 117
Error C2143 syntax error: missing ';' before '}' Project1 c:\users\stephanie\documents\visual studio 2015\projects\project1\project1\source.cpp 117
You have naked code (statements outside any function body) from line 78 to line 112, and an extra brace on line 110. Delete any extra braces and place the naked code inside the right place (the main function?)

How do I know?
The error is easy enough to see because your code is (almost) properly indented. I can tell there's an extra brace because the indentation puts two adjacent braces on the same column (on line 109-110).

The compiler looks at your code exactly once in lexical (text) order from top to bottom, remembering what it sees as it proceeds through your program (this is actually guaranteed by the language standard). This means that diagnostic messages always appear at or after the broken code, but never before.

For each diagnostic message, the compiler will give you a location referring to the spot the error was detected in your code. You should find the earliest such location in your code that shows up in your compiler output and take a close look at and before that location.
could you help me fix this? I'm still learning and trying to figure out what goes where.
You can't have all that code outside a function. There are only certain specific types of statement that can be outside any functions - basically, declarations. All other code has to be inside a function. Otherwise, when would it run?
Topic archived. No new replies allowed.