Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

(TCO 5) Write a function that takes inputs of quarts and pints (whole numbers),

ID: 3529036 • Letter: #

Question

(TCO 5) Write a function that takes inputs of quarts and pints (whole numbers), then calculates and returns an output of the total number of gallons (a floating-point value). There are 4 quarts in a gallon, and 2 pints in a quart. Use appropriate parameter passing and return mechanisms. Use appropriate datatypes. For example, with inputs of 4 quarts and 4 pints, the result would be 1.5 gallons. Use proper code formatting techniques. Do not write a main routine. Your function does not do cin or cout. (Points : 15)

Explanation / Answer

float toGallons(int q,int p) {return q*.25+p*.125; }