Question

In: Computer Science

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: height, base, and width have been declared as floating-point number on the main method.

  • The static method declaration, and method call for Trian_area have been shown on the code. The parameters: base, and height have been passed to Trian_area method to calculate the area of the triangular area. The value returned by Trian_area method has been assigned to a variable named area1

  • Task 1: Now, you need to work on the method named Rect_area which calculates the rectangular area of shape. You need to write static method declaration, and method call for Rect_area method. You need to pass local variable base, and width to theRect_area method.TheRect_area method returns the area of the rectangle to the main. You will assign the value returned by this method to area2. You will print the area of the rectangle on the terminal according to sample output.

  • Task 2: Now, add rectangle area and triangle area on the main to calculate the total surface area of the shape. Now, print total surface area of the shape on the terminal according to sample output.

Sample output 1:

Enter the value of base, height and width in feet: 10 30 20

Total surface area of the shape: 350.0 square feet

Solutions

Expert Solution

CODE -

import java.util.Scanner;

public class surf_area

{

    

    // Method to calculate triangular area of shape

    static float Trian_area(float base, float height)

    {

        float area = 0.5f * base * height;

        return area;

    }

    // Method to calculate rectangular area of shape

    static float Rect_area(float base, float width)

    {

        float area = base * width;

        return area;

    }

    // Main method

    public static void main(String[] args) {

        Scanner keyboard = new Scanner(System.in);

        float base, height, width;

        // Take base, height, and width as input from user

        System.out.print("Enter the value of base, height and width in feet: ");

        base = keyboard.nextInt();

        height = keyboard.nextInt();

        width = keyboard.nextInt();

        // Call functions to calculate triangular area and rectangular area

        float area1 = Trian_area(base, height);

        float area2 = Rect_area(base, width);

        // Calculate total surface area

        float totalSurfaceArea = area1 + area2;

        // Display total surface area

        System.out.println("Total surface area of the shape: " + totalSurfaceArea + " square feet");

        keyboard.close();

    }

}

SCREENSHOTS -

CODE -

OUTPUT -

If you have any doubt regarding the solution, then do comment.
Do upvote.


Related Solutions

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
D3 a product is either rectangular or triangular. What is the probability that, in a random...
D3 a product is either rectangular or triangular. What is the probability that, in a random sample of 10 units, there are more than 8 rectangular units of product? Round your answer to 4 decimal places. Assume that the population proportion of rectangular products is the same as the sample proportion of rectangular products Product weight (g) Product height (mm) Product colour Product shape 18 53 Yellow Rectangular 11 93 Yellow Rectangular 19 43 Red Rectangular 15 69 Red Rectangular...
Find the total volume, total surface area and the longest line for the following limits: 0...
Find the total volume, total surface area and the longest line for the following limits: 0 ≤ r ≤ 5, 0 ≤ θ ≤ π, 90° ≤ ϕ ≤ 200° 0 ≤ r ≤ 2, 20° ≤ θ ≤ 120° , 0 ≤ ϕ ≤ 180°
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!
When a sample of MegaCaff that weighs 0.5 g and has a total surface area of...
When a sample of MegaCaff that weighs 0.5 g and has a total surface area of 0.25 m2 was dissolved in water for 2 minutes, the dissolution rate constant (k) was found to be 0.01 cm/min. The saturation solubility is known to be 3.2 x 10-3 g/mL. If the material is now pressed into a tablet with surface area 2.0 cm2, what will be the effect on the dissolution rate (dM/dt) and the dissolution rate constant (k)?
A triangular number is the sum of the n natural numbers from 1 to n. For...
A triangular number is the sum of the n natural numbers from 1 to n. For example: The triangular number for 3 is 1 + 2 + 3 = 6 The triangular number for 7 is 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28 Write a program segment (using a loop), that calculates and then prints the integer n and its triangular number.
You want to build a rectangular box in such a way that the sum of the...
You want to build a rectangular box in such a way that the sum of the length, width and height is 24 cm. a) Define the equations so that the dimensions of their volume are maximum b) Which of the equations proposed would be the restriction and which function? Explain c) Using the technique you want to calculate maximums and minimums, what are these values? What volume will the box have?
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)
consider the following information for a rectangular primary clarifier a)determine the required surface area(m^2),tank volume(m^3) and...
consider the following information for a rectangular primary clarifier a)determine the required surface area(m^2),tank volume(m^3) and detention time (hrs) under both the average flow conditions and peak flow conditions b) calculate and compare the scour velocity (m/s) and peak flow horizontal velocity (m/s) Based on these two values,do you expect the particles to re-suspend during the clarification process. No of rectangular clarifiers=2 Qaverage=20,000m^3/d Qpeak=50,000m^3/d channel width =6m side water depth=4m overflow rate at average flow=40m^3/m^2.d density of water=1000kh/m^3 density of...
A rectangular area adjacent to a river is to be fenced in, but no fencing is...
A rectangular area adjacent to a river is to be fenced in, but no fencing is required on the side by the river. The total area to be enclosed is 114,996 square feet. Fencing for the side parallel to the river is $6 per linear foot, and fencing for the other two sides is $7 per linear foot. The four corner posts cost $25 apiece. Let xx be the length of the one the sides perpendicular to the river. [A]...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT