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

Write a second ConvertToInches() with two double parameters, numFeet and numInch

ID: 3760956 • Letter: W

Question

Write a second ConvertToInches() with two double parameters, numFeet and numInches, that returns the total number of inches. Ex: ConvertToInches(4.0, 6.0) returns 54.0 (from 4.0 * 12 + 6.0).

#include <iostream>
using namespace std;

double ConvertToInches(double numFeet) {
return numFeet * 12.0;
}

/* Your solution goes here */

int main() {
double totInches = 0.0;

totInches = ConvertToInches(4.0, 6.0);
cout << "4.0, 6.0 yields " << totInches << endl;

totInches = ConvertToInches(5.9);
cout << "5.9 yields " << totInches << endl;
return 0;
}

Explanation / Answer

#include <iostream>
using namespace std;
double ConvertToInches(double numFeet) {
return numFeet * 12.0;
}
double ConvertToInches(double numFeet,double numInches) {
return ConvertToInches(numFeet) + numInches;
}

/* Your solution goes here */
int main() {
double totInches = 0.0;
totInches = ConvertToInches(4.0, 6.0);
cout << "4.0, 6.0 yields " << totInches << endl;
totInches = ConvertToInches(5.9);
cout << "5.9 yields " << totInches << endl;
return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote