Question
IN C++ The following function uses reference parameters to compute the size of a chain in feet and inches given the size of the chain
IN C++
The following function uses reference parameters to compute the size of a chain in feet and inches given the size of the chain in inches, and returns the total cost of the chain. Rewrite the function so it uses pointers instead of reference parameters. double chain (int totalInches, int &feet, int &inches) { feet = totalInches/12; inches = totalInches%12; return feet*3.49 + inches*.30; } Use the main function to demonstrate your functions. Declare two int variables f and i and set them to 0. Input the size of chain in inches. Then call the chain function so the values computed for feet and inches get stored in f and i. Then output the result, and new values of f and i. Use cout << fixed << setprecision(2); to format the cost to two decimal places. Ex: If the input to the program is: 30 the output is: 2 feet and 6 inches. Cost: $8.78 Your program must define and call a function named chain with three parameters in the order described above, that returns a double value.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started