Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a C++ program to convert velocities to alternate units as described below:

ID: 3869294 • Letter: W

Question

Write a C++ program to convert velocities to alternate units as described below: Use a single 2D array with 3 columns and 21 rows for the velocity values as follows: column 0 - velocity in mi/h (mph) column 1 - velocity in km/h column 2 - velocity in ft/s The 3D array is illustrated below where velocity varies from 0-100 mi/h: Use a loop or a list to assign the velocity values to column 0. Use a loop to calculate and assign the velocities in columns 1 and 2. Neatly display the velocity in three columns with a table heading. Select a reasonable number of digits for each column.

Explanation / Answer

#include <iostream>
using namespace std;

int main() {
  
    float velocities[21][3];
    int i;
  
    //calculating values to be stored in zeroth column
    for(i=0;i<21;i++){
        velocities[i][0]=i*5;
    }
  
    //calcualting values for column 1 and 2
  
    for(i=0;i<21;i++){
        velocities[i][1]=velocities[i][0]*1.609344;
        velocities[i][2]=velocities[i][0]*5280/(3600);
    }
  
    //displaying the values in tabular format
    printf("miles/hour Kilometer/hour feet/second ");
    for(i=0;i<21;i++){
        printf("%5.6f,    %5.6f,       %5.6f ",velocities[i][0],velocities[i][1],velocities[i][2]);
    }


   return 0;
}


OUTPUT:

miles/hour Kilometer/hour feet/second
0.000000,    0.000000,       0.000000
5.000000,    8.046720,       7.333333
10.000000,    16.093439,       14.666667
15.000000,    24.140160,       22.000000
20.000000,    32.186878,       29.333334
25.000000,    40.233601,       36.666668
30.000000,    48.280319,       44.000000
35.000000,    56.327042,       51.333332
40.000000,    64.373756,       58.666668
45.000000,    72.420479,       66.000000
50.000000,    80.467201,       73.333336
55.000000,    88.513924,       80.666664
60.000000,    96.560638,       88.000000
65.000000,    104.607361,       95.333336
70.000000,    112.654083,       102.666664
75.000000,    120.700798,       110.000000
80.000000,    128.747513,       117.333336
85.000000,    136.794235,       124.666664
90.000000,    144.840958,       132.000000
95.000000,    152.887680,       139.333328
100.000000,    160.934402,       146.666672

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote