Hello I am having trouble with my C++ homework as I do not fully understand how to use a switch statement on this problem or at all. The question goes like this:
SSD = c(vt + cv^2/2g(f+G))
SSD is the stopping sight distance (m or ft)
c is the conversion factor = .278 m-hr/km-s (metric units) or 1.47 ft-hr/mi-sec (U.S. customary units)
v is the speed (km/hr or mi/hr)
t is the reaction time (sec)
g is the acceleration caused by gravity = 9.81 m/s^2 or 32.2 ft/sec^2
f is the road's coefficient of friction (dimensionless)
G is the road grade, as a decimal (dimensionless)
Using this equation, write, compile and run a C++ program that first prompts the user for the unit system to use (metric or U.S. customary units). Based on the response, your program should select the correct conversion factor, request the remaining data, and display stopping sight distance.
Can anyone help me with this? It would be much appreciated.
#include <iostream>
#include <cmath>
usingnamespace std;
int main()
{
double SSD, c, v, t, g, f, G;
char sys;
SSD = c * (v * t + (c * v *v)/(2 * g * (f + G)));
cout << "Please enter the unit system to use, Metric or English units (select m or e): ";
cin >> sys;
switch (sys)
{
case'e': // Do English calculations
break;
case'm': // Do Metric calculations
break;
default: cout << "Selection not recognized" << endl;
}
cout << "Now enter speed: ";
cin >> v;
cout << "Now enter reaction time: ";
cin >> t;
cout << "Now enter the road's coefficient of friction: ";
cin >> f;
cout << "Now enter the road grade as a decimal: ";
cin >> G;
cout << "The stopping sight distance is " << SSD << endl;
return 0;
}