In: Computer Science
Write a method to return the surface area of a right rectangular prism given the dimensions Example: surface_area(3, 5, 7) returns 142. Java Program (Using Method)
Program Code [JAVA]
public class RectangularPrism {
// surface_area method which takes three parameters length, width and height
// It will return the surface area of the right rectangular prism
public static double surface_area(double length, double width, double height) {
return 2 * ((width*length) + (height*length) + (height*width));
}
public static void main(String[] args) {
// testing surface_area method with given parameters in question
System.out.println("The surface area of right rectangular prism with parameters" +
" (3, 5, 7) is " + surface_area(3, 5, 7));
}
}
Sample Output:-
-------------------------------------------------------------------
COMMENT DOWN FOR ANY QUERIES!!!
HIT A THUMBS UP IF YOU DO LIKE IT!!!