Question

In: Computer Science

Write a method to return the surface area of a right rectangular prism given the dimensions...

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)

Solutions

Expert Solution

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!!!


Related Solutions

The total surface area is the sum of the triangular area and rectangular area. Complete the...
The total surface area is the sum of the triangular area and rectangular area. Complete the following code to compute the total surface area of the shape. ??????? ???? = 12 ∗ ???? ∗ ????h? + ???? ∗ ????h This Java program prompts for and reads in the value of height, base, and width in feet.This program uses two methods: Train_area and Rect_area to calculate the area of the triangle and the area of the rectangle, respectively. The following parameters:...
Find the dimensions of the rectangular corral producing the greatest enclosed area given 200 feet of fencing.
Find the dimensions of the rectangular corral producing the greatest enclosed area given 200 feet of fencing.
Multivariable Calculus: Surface Area and Change of Variables Find the surface area of the surface given...
Multivariable Calculus: Surface Area and Change of Variables Find the surface area of the surface given by z =18−2x−3y over the triangle with vertices: (0,0), (2,3), (4,1). Since this is not a type I or type II region, you will either need to divide the region into two regions or use a change of variables. x=(1/5)(u-2v) and y=(1/10)(3u-v) is a possible change of variables. I will upvote answers!
A rectangular box with no top is to have a surface area of 64 m2.  Find the...
A rectangular box with no top is to have a surface area of 64 m2.  Find the dimensions (in m) that maximize its volume. I got width as X= 8sqrt3/3, length y=8sqrt3/3, and height as z=4sqr3/3 but it is wrong and I don't know why
Finding Surface Area In Exercises 43-46, find the area of the surface given by z =...
Finding Surface Area In Exercises 43-46, find the area of the surface given by z = f(x, y) that lies above the region R. f(x,y)=4-x^2 R: triangle with vertices (-2,2),(0,0),(2,2)
Write a method named area with one double parameter name radius. The method needs to return...
Write a method named area with one double parameter name radius. The method needs to return a double value that represents the area of a circle. If the parameter radius is negative , then return -1.0 to present an invalid value Write another overload method with 2 parameters side1 and side2 (both double) where side1 and side2 represent the sides of a rectangle. The method needs to return an area of a rectangle . If either or both parameters is/...
Write a method named area with one double parameter name radius, the method needs to return...
Write a method named area with one double parameter name radius, the method needs to return a double value that represents the area of a circle. If the parameter radius is negative, then return -1.0 to represents an invalid value write another overload method with 2 parameter side 1 and side 2 (double) where side 1 and side 2 represents the sides of a rectangle. The method needs to return an area of a rectangle. If either or both parameters...
A flat surface of dimensions 2 m by 2 m that is given a total charge...
A flat surface of dimensions 2 m by 2 m that is given a total charge of 400 μC uniformly distributed over the surface, and where a point charge +4 μC is fixed a distance 2 cm above the centre of the charged surface. A second point charge +16 nC, with mass 10 g, is placed at rest directly above the first point charge, at a distance 2 cm from the first point charge. The second point charge is released...
Find the surface area of the given surface. Enter an exact answer. Do not use decimal...
Find the surface area of the given surface. Enter an exact answer. Do not use decimal approximations. the portion of the plane 7x + y + 6z = 2 inside the cylinder x2 + y2 = 36
You are using the rational method for calculating the surface runoff in a rural area. The...
You are using the rational method for calculating the surface runoff in a rural area. The area is flat, permeable grassland. Calculate the runoff coefficient (C).
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT