diameter of a cycle wheel is D. Given that, the cycle travels at an average speed of X km/h,
find the number of revolutions made by the wheel per minute, giving your answer to the nearest whole
number (assume PI = 3.142). Write a C++ function to calculate revolutions per minute.
#include <iostream>
using namespace std;
const double pi = 3.142;
double RevPerMin(double D, double S);
int main()
{
double D;
cout << "Enter diameter (in meters): ";
cin >> D;
cout << "Enter average speed (in km/h): ";
double S;
cin >> S;
cout << "Revolutions per minute is: " << RevPerMin(D, S) << endl;
return 0;
}
double RevPerMin(double D, double S)
{
S /= 3.6; // converse to m/s
return 60 / (D * pi / S); // D*pi/S - amount of time per revolution in seconds, 60 / - it is number of seconds in a minute
}
Comments
Leave a comment