end of file found befor braces

Help.. I have counted my braces and it look to be correct but I am seeing double.. I am getting the "end of file found before the left brace.. do I have one in an incorrect place?

Thanks!


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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#include <iostream>
#include <string>
#include <fstream>
#include<cmath>
using namespace std;

int totalCaloriesBurned (double);

int main()
{
	ifstream inputFile;
	int exercise2;
	int workout;
	string exercise;


	cout << "How was your workout today Martha? Enter 1 for Excellent,\n2 for okay and 3 for bad.    ";
	cin >> workout;
	cout << endl;

	if (workout == 1)
		cout << "Excellent, lets get to recording the workout!" << endl;

	else if (workout == 2)
		cout << "Only Okay, maybe work harder next time, lets get to recording your workout!" << endl;

	else if (workout == 3)
		cout << "Having a bad day, sorry to hear that, lets get to recording your workout!" << endl;

	else
		cout << "Please enter a number between 1 and 3" << endl;
	cout << endl;
	cout << endl;

	cout << "Please select from the following list\n";
	cout << "of exercises:" << endl;
	cout << endl;

	inputFile.open("E:\\Final Project\\exercise.txt");

	inputFile >> exercise;
	cout << "1) " << exercise << endl;
	inputFile >> exercise;
	cout << "2) " << exercise << endl;
	inputFile >> exercise;
	cout << "3) " << exercise << endl;
	inputFile >> exercise;
	cout << "4) " << exercise << endl;
	inputFile >> exercise;
	cout << "5) " << exercise << endl;
	inputFile >> exercise;
	cout << "6) " << exercise << endl;
	inputFile >> exercise;
	cout << endl;

	inputFile.close();

	int minutes, day1, day2, day3, day4, day5, day;
	double caloriesBurned;
	double calories1 = 4, calories2 = 7, calories3 = 8, calories4 = 2, calories5 = 8, calories6 = 9;;

	for (day = 0; day <= 5; day++)
	{
		cout << "enter your first days exercise: " << endl;
		cin >> day;


		cout << "From the list above please select\n";
		cout << "your workout number from 1-6:     ";
		cin >> exercise2;
		cout << endl;

		while (exercise2 == 1)
		{
			cout << "For how many minutes did you exercise?    ";
			cin >> minutes;
			cout << endl;
			caloriesBurned = minutes * calories1;
			cout << "You burned " << caloriesBurned << " during your workout today\n";
			cout << "Great Job!  :-)" << endl;
			cout << endl;
			break;
		}

		while (exercise2 == 2)
		{
			cout << "For how many minutes did you exercise?    ";
			cin >> minutes;
			cout << endl;
			caloriesBurned = minutes * calories2;
			cout << "You burned " << caloriesBurned << " during your workout today\n";
			cout << "Great Job!  :-)" << endl;
			cout << endl;
			break;
		}
		while (exercise2 == 3)
		{
			cout << "For how many minutes did you exercise?    ";
			cin >> minutes;
			cout << endl;
			caloriesBurned = minutes * calories3;
			cout << "You burned " << caloriesBurned << " during your workout today\n";
			cout << "Great Job!  :-)" << endl;
			cout << endl;
			break;
		}
		while (exercise2 == 4)
		{
			cout << "For how many minutes did you exercise?    ";
			cin >> minutes;
			cout << endl;
			caloriesBurned = minutes * calories4;
			cout << "You burned " << caloriesBurned << " during your workout today\n";
			cout << "Great Job!  :-)" << endl;
			cout << endl;
			break;

		}
		while (exercise2 == 5)
		{
			cout << "For how many minutes did you exercise?    ";
			cin >> minutes;
			cout << endl;
			caloriesBurned = minutes * calories5;
			cout << "You burned " << caloriesBurned << " during your workout today\n";
			cout << "Great Job!  :-)" << endl;
			cout << endl;
			break;
		}
		while (exercise2 == 6)
		{
			cout << "For how many minutes did you exercise?    ";
			cin >> minutes;
			cout << endl;
			caloriesBurned = minutes * calories6;
			cout << "You burned " << caloriesBurned << " during your workout today\n";
			cout << "Great Job!  :-)" << endl;
			cout << endl;
			break;
		}
	}
	cout << "Your total calories burned:  ";
	cout << "during your workouts is:  " << totalCaloriesBurned << endl;



	system("pause");
	return 0;
}



	double totalCalriesBurned(double day1, double day2, double day3, double day4, double day5);
	{
		int result;
		result = day1 + day2 + day3 + day4 + day5;
		return result;

	}[code][/code
]
Return types, number of parameters and spelling of function name in the function prototype and definition don't match. And remove the semicolon at the end of the function definition line.

int totalCaloriesBurned (double);

double totalCalriesBurned(double day1, double day2, double day3, double day4, double day5); //<--

Are you trying to call the function here? If yes, you need the () with the arguments the function expects to receive.

cout << "during your workouts is: " << totalCaloriesBurned << endl;
Last edited on
I really am not sure I totally understand the functions. I am trying to call it yes at the end of "during your workout is: ". Is this not the correct way to do it.

I need to put (double) after in on the last line above?
Your prototype says that you will send the function one argument of type double, and that the function will return a variable of type int.

int totalCaloriesBurned (double);


Your function says it will take 5 double arguments and return a double. Since you seem to want to add the values of 5 days and return the total, I'd update the prototype to return a type double instead of int, and have 5 doubles within the parenthesis. In the function body, result would also be a double, but you don't really need to declare a new variable, you can just return the sum of the days.
1
2
3
4
5
6
7
double totalCaloriesBurned(double day1, double day2, double day3, double day4, double day5)
	{
		int result;
		result = day1 + day2 + day3 + day4 + day5;
		return result;

	}



When you call the function - call it with the arguments in parenthesis after the name. I'm assuming you meant to send day1, day2, day3, day4, day5, but you don't actually set those variables in the main function. And they'd be doubles instead of ints?
cout << "during your workouts is: " << totalCaloriesBurned(variable names here) << endl;
Thank you! I have updated all of those! I am still getting the following error though?

Error 1 error C1075: end of file found before the left brace '{' at 'c:\users\tonka\documents\visual studio 2013\projects\final_project\final_project\final_project.cpp(15)' was matched c:\users\tonka\documents\visual studio 2013\projects\final_project\final_project\final_project.cpp 165 1 Final_Project


Am I missing a brace?
Did you take out the semicolon at the end of this line?

 
double totalCaloriesBurned(double day1, double day2, double day3, double day4, double day5); //<-- 
yes!
Topic archived. No new replies allowed.