convertLengths

convertLengths - distanceOut converted distance measure d...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
// filename: convertLengths.cpp // author: j. dzuback // date: 10/02/09 /* ******************************************************* The program converts metres to furlongs and furlongs to metres. User enters a letter -- "K" for kilometre or "F" for furlong -- followed by a numeric value. If the unit of measure is "F" (furlong), the program will convert the value entered to kilometres. If the unit of measure is "K" (kilometre), the program will convert the value entered to furlongs. ******************************************************* */ * #include <iostream> #include <iomanip> # using namespace std; u const double FURLPERKM = 4.97097; const double KMPERFUR = 0.201168; c int main() { char unitOfMeasure; // place to store distance measure int distanceIn; // distance measure to convert double
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: distanceOut; // converted distance measure d cout << fixed << showpoint << setprecision(3); cout << endl << "Input Menu" << endl << endl; cout << "K: Convert from kilometre to furlong" << endl; cout << "F: Convert from furlong to kilometre" << endl; cout << "Type an K or an F and press return "; cin >> unitOfMeasure; cout << endl << "Enter an integer, then press return "; cin >> distanceIn; c if (unitOfMeasure == 'K') distanceOut = double(distanceIn) * FURLPERKM; else distanceOut = double(distanceIn) * KMPERFUR; cout << "Distance to convert: " << setw(6) << float(distanceIn) << endl; cout << "Converted distance: " << setw(6) << distanceOut << endl; c cout << endl << "***** end of convertLengths.cpp *****"; return 0; } // end of main...
View Full Document

This note was uploaded on 02/08/2011 for the course CSC 101 taught by Professor Joedzuback during the Spring '11 term at Union County.

Ask a homework question - tutors are online