Sep 20, 2015 at 2:18am UTC
Hey guys, brand new to this and have to write a program for converting distances displaying labels, and numbers with 3 digits to the right of the decimal. Keep getting errors for expected constructor, destructor, or type conversion and undeclared variables. I've tried to make multiple changes and keep getting errors, so any help would be greatly appreciated.
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
// constants
constant double m = miles
constant double f = m*5280.0; // feet = miles*5280.0
constant double i = f*12.0; // inches = feet*12.0
constant double c = i*2.54; // centimeters = inches*2.54
constant double r = c/100; // meters = centimeters/100
constant double k = r/1000; // kilometers = meters/1000
int main()
{
//variable
variable double m; //distance in miles
cout << "Enter distance in miles";
// convert to feet
cin >> m;
cout << fixed;
cout << setprecision(3) << m << endl;
cout << m << "miles is" << endl << f << "feet" << endl;
// convert to inches
cout << fixed;
cout << setprecision(3) << f << endl;
cout << f << "feet is" << endl << i << "inches" << endl;
// convert to centimeters
cout << fixed;
cout << setprecision(3) << i << endl;
cout << i << "inches is" << endl << c << "centimeters" << endl;
// convert to meters
cout << fixed;
cout << setprecision(3) << c << endl;
cout << c << "centimeters is" << endl << r << "meters" << endl;
// convert to kilometers
cout << fixed;
cout << setprecision(3) << r << endl;
cout << r << "meters is" << endl << k << "kilometers" << endl;
return 0;
}
Last edited on Sep 20, 2015 at 2:34am UTC