// // convert3.cpp // CSC 215 // John Rogers // // This program converts from either Mexican Pesos or Canadian // dollars to American dollars. It checks its input to make // certain that a legal value for the type of currency is // entered. // #include #include int main() { float CanadianDollars, USDollars, MexicanPesos, exchangeRate; char CurrencyType; cout << "Enter M to convert from Mexican Pesos and C to "; cout << "convert from Canadian dollars: "; cin >> CurrencyType; if (CurrencyType == 'M' || CurrencyType == 'm') { exchangeRate = 7.60; cout << "Please enter the amount of Mexican pesos: "; cin >> MexicanPesos; USDollars = MexicanPesos / exchangeRate; } else if (CurrencyType == 'C' || CurrencyType == 'c') { exchangeRate = 1.48; cout << "Please enter the amount of Canadian dollars: "; cin >> CanadianDollars; USDollars = CanadianDollars / exchangeRate; } else { cout << "The currency type must be either M or C." << endl; // // The call to the exit() function kills the program. It's // defined in the header file stdlib.h. // exit(1); } cout.setf(ios::fixed); cout.setf(ios::showpoint); cout.precision(2); cout << "That amount in US dollars is: $" << USDollars << endl; return 0; }