Your friend Amanda who lives in the United States just bough
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: [if !supportEmptyParas] [endif] MPH = KPH * 0.6214 [if !supportEmptyParas] [endif] 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.)
Solution
This will be the program:
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int KPH, MPH;
cout << “Table of speeds in kilometers per hour\ ”
<< “converted to miles per hour.\ \ ”
<< “Kilometers per hour miles per hour\ ”
<< “——————————————\ ”;
for (KPH = 60; KPH <= 130; KPH += 5)
{
MPH = KPH * 0.6214;
cout << right << setw(10) << KPH;
cout << setw(25) << MPH << endl;
}
cout << endl;
return 0;
}
