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: 3761454 • 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).

FOR JAVA PLEASE

import java.util.Scanner;

public class FunctionOverloadToInches {

public static double convertToInches(double numFeet) {

return numFeet * 12.0;

}

/* Your solution goes here */

public static void main (String [] args) {

double totInches = 0.0;

totInches = convertToInches(4.0, 6.0);

System.out.println("4.0, 6.0 yields " + totInches);

totInches = convertToInches(5.9);

System.out.println("5.9 yields " + totInches);

return;

}

}

Explanation / Answer

import java.util.Scanner;

public class FunctionOverloadToInches {

public static double convertToInches(double numFeet) {
return numFeet * 12.0;
}

public static double convertToInches(double numFeet, double numInches) {
return numFeet * 12.0 + numInches;
}


public static void main (String [] args) {
double totInches = 0.0;

totInches = convertToInches(4.0, 6.0);
System.out.println("4.0, 6.0 yields " + totInches);

totInches = convertToInches(5.9);
System.out.println("5.9 yields " + totInches);
return;
}
}

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