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...
_____ do not need any previous training in computers or expert systems.
A. Domain experts B. Knowledge users C. Knowledge engineers D. Intelligent agents
By creating a free app, Norton might gain a(n) ________
Fill in the blank(s) with correct word
A ____ is a marker placed in a program that pauses program execution when it is reached.
A. marker B. pointer C. link D. breakpoint
An interpreter is a program that interprets the text of a program one word at a time, and performs the actions specified in the text. The following are examples of interpreters except:
What will be an ideal response?