/*--------------------------------------------------------------------*/ /* Program problem 24 */ /* */ /* This program prints a conversion table from pesos to dollars. */ /* The pesos values start at 5, increment by 5, */ /* print 25 lines. */ /* A for loop is used */ #include #include using namespace std; int main() { // Declare and initialize variables. int pesos=5, i; double dollars; // 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 << "Pesos to Dollars " << endl; cout << " Pesos Dollars" << endl; for(i=1; i<=25; i++) { dollars = pesos /9.02; cout << setw(7) << pesos << setw(15) << dollars << endl; pesos = pesos + 5; } // Exit program. return 0; }