/*--------------------------------------------------------------------*/ /* Program problem 22 */ /* */ /* This program prints a conversion table from mph to ft/s. */ /* The mph values start at 0, increment by 5 mph, */ /* and go through 65 mph. */ /* The first line contains the value for zero mph and the */ /* last line contains the value for 65 mph. */ /* A while loop is used */ #include #include using namespace std; int main() { // Declare and initialize variables. int mph=0; double feet; // Set formats cout.setf(ios::fixed); cout.precision(3); /* Formatting the output is optional. But it is nice to have a table printed with format */ // Print title and table cout << "mphs to feet/s " << endl; cout << " mphs feet/s" << endl; while (mph <= 65 ) { feet = mph * 5280.0/3600.0; cout << setw(7) << mph << setw(15) << feet << endl; mph = mph + 5; } // Exit program. return 0; }