94.1k views
0 votes
Write a second ConvertToInches() with two double parameters, numFeet and numInches, that returns the total number of inches.

1 Answer

3 votes

Answer:

Answered in C++

double ConvertToInches(double numFeet, double numInches){

return numFeet*12 + numInches;

}

Step-by-step explanation:

A foot is equivalent to 12 inches. So, the function converts feet to inches by multiplying the number of feet by 12.

The question is answered in C++

This line defines the method with two parameters

double ConvertToInches(double numFeet, double numInches){

This line converts the input parameters to inches and returns the number of inches

return numFeet*12 + numInches;

}

To convert 9 feet and 12 inches to inches, the main method of the program can be:

int main(){

cout<<ConvertToInches(9,12);

return 0;

}

This above will return 120 because: 9 * 12 + 12 = 120 inches

User William Everett
by
4.7k points