Question: Q2B. Write a function, calculateIFYM, which takes in an argument in metres. If the argument is zero or positive, calculateIFYM should return true - and
Q2B. Write a function, calculateIFYM, which takes in an argument in metres. If the argument is zero or positive, calculateIFYM should return true - and returns the number of miles, yards, feet, and inches the argument represents. If the argument if negative, the distance in invalid: the function should return false instead, and not return any updated values for miles, yards, feet, and inches.
Note that:
there are 39.37 inches in a metre
there are 12 inches in a foot
there are 3 feet in a yard
there are 1760 yards in a mile
The answer must be expressed using the largest units possible, i.e. an irreducible value --for example, if the input is 2001.50 meters (78799.055 inches) you must present this as 1 mile, 428 yards, 2 feet, and 7.055 inches. Hint: calculations will be simplified if you convert meters to inches, first. language code C++
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
