Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Here is the problem Shirlee is working with a measurement tool that reports meas

ID: 3646611 • Letter: H

Question

Here is the problem

Shirlee is working with a measurement tool that reports measurements in centimeters. Since Shirlee is unfamiliar with centimeters, she would like her centimeter measurements to be converted into yards, feet, and inches. She would also like the result to be properly rounded to the nearest inch. As an example, if the measurement is 312 centimeters, this should be converted to 3 yards, 1 foot, and 3 inches.


Here is my program



#include<iostream>
using namespace std;

const double CENTIMETERS_PER_INCH = 2.54;
const int INCHES_PER_FOOT = 12, INCHES_PER_YARD = 36


int main()
{
double centimeters;
int INCHES;
int FEET;
int YARDS;
int totalinches;

cout << " Enter the amount of centimeters to be converted ";
cin >> centimeters;
cout << endl;

totalinches = centimeters / CENTIMETERS_PER_INCH;

YARDS = totalinches / INCHES_PER_YARD;

FEET = ( totalinches - ( INCHES_PER_YARD * YARDS)) /12;

INCHES = ( totalinches % (INCHES_PER_YARD * YARDS)) - INCHES_PER_FOOT;


cout << YARDS << " yd " << FEET << " ft " << INCHES << " in ";



return 0;

}





I've been correcting this program for awhile now, and I just can't seem to get it to work. After I build a solution it says "int" should be preceded by ";". I've tried that, and it still didn't work. I'm also getting conversion from double to int, possible loss of data. Can anyone tell me where I've gone wrong?


Explanation / Answer

To ensure no loss of data through the implicit conversion feature of the C++ language, declare all the required variables as "double" datatype. This makes u realize accrate answers. Declaration would be in a single line as follows, double centimeters,INCHES,YARDS,FEETS,totalinches;