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

Your friend Amanda, who lives in the United States, just bought an antique Europ

ID: 3641205 • Letter: Y

Question

Your friend Amanda, who lives in the United States, just bought an antique European sport car. The car’s speedometer works in kilometer per hour. The formula for the converting kilometers per hour to mils per hour is:

MPH = KPH * 0.6214

In the formula, MPH is the speed in miles per hour and KPH is the speed in kilometers per hour. Amanda is afraid she will get a speeding ticket, and has asked you to write a program that displays a table of speeds in kilometers per hour with their values converted to miles per hour. The table should display the speeds from 60 kilometers per hour through 130 kilometers per hour, in increments of 5 kilometers per hour (in other words, it should display 60 KPH, 65 KPH, 70 KPH and so forth, up through 130 KPH.)

Explanation / Answer

#include <iostream>
#include <iomanip>

using namespace std;

int main()
{
   const double MPH_PER_KPH = 0.6214;

   for (int kph = 60; kph <= 130; kph += 5)
   {
      cout << setw(3) << kph << " KPH"
           << fixed << setprecision(2)
           << setw(9) << kph * MPH_PER_KPH << " MPH"
           << endl;
   }

   cin.get();
   return 0;
}

Dr Jack
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote