Why am I getting negative doubles?

I'm doing a physics exercise to calculate how long it would take a sled to get to the bottom of a hill. I'm getting mostly negative numbers in my output line. For example, if I enter "50" for both hill and slope, I get "It will take you -1 minutes and -17 seconds to get down the hill." What am I doing wrong (and are there better ways to break my answer into minutes and seconds)?

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
#include <stdio.h>
#include <math.h>
#include <iostream>
using namespace std;

//Constant declarations
const double GRAVITY_ACCEL = 9.8;

//Function declarations
double getAcceleration ( double angle );

int main () {
	double hill, slope, answer;
	cout << "What is the length of the hill in meters? ";
	cin >> hill;
	cout << endl << "What is the slope of the hill? ";
	cin >> slope;
	
	answer = hill / getAcceleration( slope );

	cout << "It will take you " 
             << floor(answer / 60) 
             << " minutes and " 
             << (int)answer % 60 
             << " seconds to get down the hill."
	     << endl;

	system("PAUSE");
	return 0;
}

/*Function definitions
---Acceleration of a sleigh sliding down a hill 
is a = g sin a , where a is the slope of the hill, 
and the gravity acceleration g = 9.8 meters per second*/
double getAcceleration ( double ang ) {
	return sin(ang) * GRAVITY_ACCEL;
}
sin works in radians. sin 50 is about -0.26.
Topic archived. No new replies allowed.