simple question

I get an error above time, dist0 and dist1 saying expected a deceleration. I don't know why it does this, is it because I'm using const double?

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
/*
Program: repair2a:	this program prompts for the the velocities (v0, v1) of two approaching
vehicles and their distance (d) apart,
then displays the time they meet and the distance each travels.
Example:
If d is 100, v0 is 75, and v1 is 25,
time is 1.00, distance0 is 75.000, distance1 is 25.00
If d is 151.5, v0 is 65.2, v1 is 42.8,
time is 1.403, distance0 is 91.141, distance1 is 60.039
Add the missing first line of the function and add the function declaration
DO NOT make any other changes
DO NOT us unnecessary refernce parameters
*/

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

void meet(const double d, const double v0, const double v1, const double time, const double distance0, const double distance1); //Function Declaration goes here


int main(void)
{
	double d, v0, v1, time, distance0, distance1;

	cout << "Enter d, v0, v1: ";
	cin >> d >> v0 >> v1;

	meet(d, v0, v1, time, distance0, distance1);

	cout << fixed << setprecision(3);
	cout << "Time is " << time << " distance0 is " << distance0
		<< " distance1 is " << distance1 << endl;

	return 0;
}


void meet(const double d, const double v0, const double v1, const double time, const double distance0, const double distance1);// First line of the function goes here
{
	time = d / (v0 + v1);
	dist0 = v0 * time;
	dist1 = v1 * time;
}
remove the semi-colon from end of line 39, compile your code and go through the error messages
Topic archived. No new replies allowed.