Ok I have to print two charts: one showing kilometers per hour converted to miles per hour and the second showing degrees Celsius converted to degrees Fahrenheit.
The speed conversion table should list speeds from 50 to 130 kilometers in increments of 5. (50, 55, 60 …)
The temperature conversion table should list degrees Celsius from 0 to 100 in increments of 4. (0, 4, 8 …)
Make sure to right justify the numbers in the columns.
Decimal values should be printed with one decimal place.
You should use a for loop to print each chart.
Use constants for the conversion factors.
I have the two charts and the celsius and and kilometers going in the right increments, but I can't get them to correctly convert. What's wrong with my code?
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int MPH;
int KPH;
MPH = KPH * 0.6214;
cout << "kilometers \tmiles\n";
cout << "per hour \tper hour\n\n";
cout << "========\t========\n\n";
cout << fixed << setprecision (1);
for ( int MPH = 50; MPH <= 130 ; MPH +=5)
cout << setw (5) << MPH << "\t\t" << MPH << setw(5) << endl;
cout << endl<< endl;
cout << "\t===========\n";
cout << "\tConversions\n";
cout << "\t===========\n\n\n";
cout << "Celsius \tFahrenheit\n";
cout << "========\t========\n\n";
cout << fixed << setprecision (1);
int C;
for( C = 0; C <= 100; C += 4)
cout << setw(5) << C << " \t\t" <<((9/5) * C + 32) << setw(5) << endl;
cout << endl<< endl;
cout <<endl;
cout <<endl;
system ("pause");
return 0;
}