Question
1 // This program converts the speeds 60 kph through 2 // 130 kph (in 10 kph increments) to mph. 3 #include 4 #include 5
1 // This program converts the speeds 60 kph through
2 // 130 kph (in 10 kph increments) to mph.
3 #include
4 #include
5 using namespace std;
6
7 int main()
8 {
9 // Constantsfor the speeds
10 const int START KPH = 60, //Starting speed
11 END_KPH = 130, // Ending speed
12 INCREMENT= 10; // Speed increment
13
14 // Constant for theconversion factor
15 cont doubleCONVERSION_FACTOR = 0.6214;
16
17 // Variables
18 intkph; // To hold speeds in kph
19 doublemph: // To hold speeds inmph
20
21 // Set the numeric outputformatting.
22 cout << fixed <
24 // Display the tableheadings.
25 cout <<"KPH/tMPH";
26 cout <<"---------------";
27
28 // Display the speeds.
29 for (kph = START_KPH; kph<= END_KPH; kph += INCREMENT)
30 {
31 //Calculate mph
32 mph = kph * CONVERSION_FACTOR;
33
34 // Display the speeds in kph and mph.
35 cout << kph << "t" << mph <
37 }
38 return 0;
39 }
Program Output
KPH MPH
---------------
60 37.3
70 43.5
80 49.7
90 55.9
100 62.1
110 68.4
120 74.6
130 80.8
****add the following in the code listing****
(a) Conversion from MPH to KPH
(b) conversion factorCONVERSION_FACTOR_M_TO_K = 1.6093
(c) Convert from 20 MPH to 100MPH in 10 MPH increments
(d) Output the results in anadditional table.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started