Help with c++

Status
Not open for further replies.

grumpps16

Honorable
Feb 21, 2012
1
0
10,510
HI,

I'm a bit stuck on this problem. I need to find the distance and velocity that a wheel would travel given the wheel radius, angular rate of revolutions per second and time the wheel traveled.

Here's what I got so far. The results are super large numbers, sometimes in the negative. Help!
#include <cstdlib>
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
float wheelRadius, angularRate, time, distance, revolutions, velocity,
angularVelocity, rotationalVelocity ;
const float PI = 3.14;

cout.setf(ios::fixed,ios::floatfield);

cout << "Please enter the Wheel Radius, Angular Rate and Time"
<< endl;
cout << "your Robot traveled" << endl;
cout << "Enter three zeros to stop" << endl << endl;
cin >> wheelRadius, angularRate, time;

while (wheelRadius > 0) {
revolutions = angularRate * time;
distance = wheelRadius * revolutions * PI * 2;
velocity = wheelRadius * angularRate * PI * 2;

cout.precision(2);
cout << "For a robot having wheels of radius " << wheelRadius
<< " meters and an angular rate of " << angularRate
<< " revolutions per second traveling for " << time
<< " seconds, the distance traveled is " << distance
<< " meters and the velocity is " << velocity
<< " meters per second." << endl << endl;


cout << "Please enter the Wheel Radius, Angular Rate and Time"
<< endl;
cout << "your Robot traveled" << endl;
cout << "Enter three zeros to stop" << endl;
cin >> wheelRadius, angularRate, time;
} //end of loop

system ("PAUSE");
return EXIT_SUCCESS;
}
 
Status
Not open for further replies.