105k views
5 votes
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).

User Astef
by
6.1k points

2 Answers

4 votes

Answer:

public static double convertToInches ( double numFeet, double numInches ){

return ((numFeet * 12.0) + numInches);

}

Step-by-step explanation:

You're creating a second method that has the same name. It's very similar to the one above it (see the picture attached) just changing the parameters and adding on + numInches to the end of the return statement.

Write a second converttoinches() with two double parameters, numfeet and numinches-example-1
User Aalap
by
6.8k points
6 votes

Answer:

Answer is in java language

Step-by-step explanation:

I am writting the code with comments in lines that starts with "//".

//First write the method converttoinches having two input parameters

// 1st param numfeet

// second param numinches

// public is a access modifier in which this method can be accessed

// from any class

//double is a return type as we have both input param as double so the

// the return value will also be double as well

public double converttoinches(double numfeet, double numinches) {

// In programming languages any numeric value that is in parenthesis

// will execute first so as we want to multiple numfeet with 12 in order to

//get number of inches in feet and then add those values with //numinches

// return will send the result from this function to where its being called.

return (numfeet * 12) + numinches;

}

User Fuxi
by
7.4k points