help plz!! Write a program that will convert miles to kilometers and kilometers
ID: 645671 • Letter: H
Question
help plz!!
Write a program that will convert miles to kilometers and kilometers to miles. The user will indicate both a number (representing a distance) and a choice of whether that number is in miles to be converted to kilometers or kilometers to be converted to miles. Each conversion is done with a value returning function. You may use the following conversions. 1 kilometer = .621 miles 1 mile = 1.61 kilometers Compile and run the program using the data in the example screen capture on the next page. Take a screen capture of the program running and paste in the document titled Lesson Set 6.2 Screen Captures.Explanation / Answer
#include <iostream>
using namespace std;
void kiloToMeter ()
{
double m;
cout << "Please input the kilometers to be converted" << endl;
cin >> m;
cout << m << " kilometers to " << (m * 0.621) << " miles" << endl;
}
void meterToKilo ()
{
double m;
cout << "Please input the miles to be converted" << endl;
cin >> m;
cout << m << " meters to " << (m * 0.621) << " kilometers" << endl;
}
int main ()
{
int choice;
cout << "Please input " << endl;
cout << "1 Convert miles to kilometers " << endl;
cout << "2 Convert kilometers to miles " << endl;
cout << "3 Quit " << endl;
cin >> choice;
switch(choice)
{
case 1:
meterToKilo();
break;
case 2:
kiloToMeter ();
break;
case 3:
break;
}
//system("Pause");
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.