#include<iostream>
using namespace std;
class Dist
{
int feet;
float inches;
public:
enter()
{
cout<<"\nenter feet ";
cin>>feet;
cout<<"\nenter inches";
cin>>inches;
}
display()
{
cout<<feet<<"'-"<<inches;
}
scale(Dist d1, float scalefactor)
{
d1.feet= d1.feet*scalefactor;
d1.inches=d1.inches*scalefactor;
while(d1.inches>=12)
{
d1.inches=12-d1.inches;
d1.feet++;
}
};
main()
{
Dist d1,d2;
d1.enter();
d1.scale(d1,0.5);
d1.display();
} //error is in this line
error is in the last line. This code is the solution for the question
Define a class Dist with int feet and float inches. Define member function that displays distance in 1’-2.5” format. Also define member function scale ( ) function that takes object by reference and scale factor in float as an input argument. The function will scale the distance accordingly. For example, 20’-5.5” and Scale Factor is 0.5 then answer is 10’-2.75”