What is the incorrect action and why does it occur?
Specification: The Convert class performs conversions from miles to inches. We need to convert 2.5 miles to inches. (Recall that there are 5,280 feet in a mile, 12 inches in a foot.)
```
#include
using namespace std;
class Convert
{
private:
double miles, inches;
public:
Convert(){ miles = 0.0; inches = 0.0; }
Convert(double m){miles = m; }
double Miles2Inches();
};
double Convert::Miles2Inches()
{
inches = miles * 5208.0 * 12.0;
return inches;
}
int main()
{
Convert MyMiles(2.5), MyOtherMiles;
double MyInches;
MyInches = MyOtherMiles.Miles2Inches();
cout << “\n Total inches are “ << MyInches;
return 0;
}
```
If this program were executed, the output would be 0.0.
There is one calculation error in this program. The number of feet in a mile is 5,280 and it is entered as 5208.
The logic error in this program is that we set the 2.5 miles into the MyMiles object, but then call the Miles2Inches function by using the MyOtherMiles object (which contain zeros for inches and miles). The MyMiles object should call its Miles2Inches function and then MyInches would be correct.
MyInches = MyMiles.Miles2Inches();
You might also like to view...
(What Does this Program Do?) What does the following program print?
```
// Mystery2.cpp
#include
AJAX is an acronym for ____.
A. Asynchronous JavaScript and XML B. Action JavaScript and XML C. Asynchronous Java and XML D. Asymmetric JavaScript and XML