program not building, "expecting unqualified-id"

I'm trying to build a MPH calculator using a function header other than main.

These are the instructions:
Write a program that will input miles traveled and hours spent in
travel. The program will determine miles per hour. This calculation must
be done in a function other than main; however, main will print the
calculation. The function will thus have 3 parameters: miles, hours, and
milesPerHour. Which parameter(s) are pass by value and which are
passed by reference? Output is fixed with 2 decimal point precision.

I'm getting an error on line 2 (at the first brace in the code) stating "Expected unqualified-id", but I am unclear on how to fix this issue. Here's the code:

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
     double milesPerHour(int miles, int hours);
{
    return miles / hours;
}

    #include<iostream>
    #include<iomanip>

double milesPerHour(int miles, int hours);

	int main()

	{
        using namespace std;
        int miles, hours;
    

        
		cout << "Please enter the miles traveled" <<endl;
		cin >> miles;
		cout << "Please enter the hours traveled" <<endl;
		cin >> hours;
		cout << setprecision(2) << fixed;
		cout << "your speed is " << milesPerHour << " miles per hour" <<endl;
    
		system("pause");
		return 0;
	}
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
#include<iostream>
#include<iomanip>

     double milesPerHour(double miles, double hours)
{
    if ( hours == 0 )
      return 0;
    return miles / hours;
}

	int main()

	{
        using namespace std;
        double miles, hours;
    

        
		cout << "Please enter the miles traveled" <<endl;
		cin >> miles;
		cout << "Please enter the hours traveled" <<endl;
		cin >> hours;
		cout << setprecision(2) << fixed;
		cout << "your speed is " << milesPerHour( miles, hours ) << " miles per hour" <<endl;
    
		system("pause");
		return 0;
	}
Perfect, thank you!
Topic archived. No new replies allowed.