Answers
/* * C++ Program to Calculate Stopping Site Distance */ #include <iostream> #include <cstdio> using namespace std; #define gM 9.81 #define gF 32.2 #define cM 0.278 #define cF 1.47 int main() { int ch; cout << "Enter choice of units -" << endl; cout << "1. Metric" << endl; cout << "2. U.S. Customery Units" << endl; cout << "Enter Choice: "; cin >> ch; int v; float t, f, G; double SSD; switch(ch) { case 1: cout << "Enter speed (km/h): "; cin >> v; cout << "Enter reaction time (sec): "; cin >> t; cout << "Enter Coefficient of friction: "; cin >> f; cout << "Enter Road Grade: "; cin >> G; SSD = (cM*v*t) + ((cM*cM*v*v)/(2*gM*(f + G))); cout << "SSD: " << SSD << " m"; break; case 2: cout << "Enter speed (mi/h): "; cin >> v; cout << "Enter reaction time (sec): "; cin >> t; cout << "Enter Coefficient of friction: "; cin >> f; cout << "Enter Road Grade: "; cin >> G; SSD = (cF*v*t) + ((cF*cF*v*v)/(2*gF*(f + G))); cout << "SSD: " << SSD << " ft"; break; } return 0; } /* Program ends here */
Note: The complete program is tested and the output is attached, please wait the table is being updated. I will attach once it is done.
Metric 2 C++ Program to Calculate Stopping Site Distance #include <iostream> 6 #include <cstdio> 2. U.S. Customery Unit:s Enter Choice: 2 7 using namespace std; Enter speed (mi/h):30 Enter reaction time (sec): 1.5 Enter Cocfficient of friction: 0.47 Enter Road Grade:-0.03 SSD: 134.784 ftl #define gM 9.81 @define gF 32.2 1θ 11 #define cM0.278 12 #definecF 1.4 13 14 int main() 15 int ch; 16 17 18 cout << "Enter choice of units -"<< endl; 19 cout << "1" Metric" くくendl; cout << "2. U.S.Customery Units << endl; cout << "Enter Choice: "; cin > ch; 2e 21 23 24 float t, f, G; double SSD; 25 26 27 28 Switch(ch) 29 case 1: 30