Thanks so much for your response. But I don't think I'm allowed to use anything other than:
#include <iostream>
using namespace std;
as a header in this class. I don't think my professor allows <cmath> in this intro class.
Is there a way to do this using only <iostream>?
#include <iostream>
usingnamespace std;
int main(void)
{
int feet = 0;
double inches = 0;
double metres = 0;
int number;
cout
<< "1. Convert length from Metric to English\n"
<< "2. Convert length from English to Metric\n"
<< "3. Quit the program\n"
<< '\n'
<< "Please enter your choice: ";
cin >> number;
if (number == 1)
{
cout << "Enter the number of meters as a double: ";
cin >> metres;
inches = metres * 1000 / 25.4; // 1" = 25.4 mm exactly
feet = inches/12;
inches = inches - feet * 12;
cout << metres << " meters corresponds to " << feet << " feet " << inches << " inches\n";
}
}
1. Convert length from Metric to English
2. Convert length from English to Metric
3. Quit the program
Please enter your choice: 1
Enter the number of meters as a double: 75
75 meters corresponds to 246 feet 0.755906 inches
Program ended with exit code: 0