Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

CSC60A Quix Refer to the code segment below that computes the area of the triang

ID: 3724465 • Letter: C

Question

CSC60A Quix Refer to the code segment below that computes the area of the triangle. Read the comments and complete the missing codes in the underlined spaces provided Note: The area of triangle- O.5 base height publie class Triangle (a/Declare three instance variables base, height, area of type double public void setTriangle ( (by//This method assigns the parameter base to instance variable base and parameter height to instance variable height public void setTriangle (e)//This method calculates area of triangle 0.5·base . height public void display (d)//This methed displays the area of triangle public class TriangleDriver public static void main(Stringll args) (e)/Create an object called TI of Triangle class (D//Call the instance method set Triangle_hase height to set the triangles base as 5.0 and height as (R/Call method area to compute the area of the triangle (h)/Call method to display the area of the triangle

Explanation / Answer

public class triangle

{

double base;

double height;

double area;

public void setTriangle(double base,double height)

{

this.base=base;

this.height=height;

}

public void setTriangle()

{

area=0.5*base*height;

}

public void display()

{

System.out.println("The area of triangle is "+area);

}

public class TriangleDriver

{

public static void main(String[] args)

{

Triangle t1=new Triangle();

t1.setTriangle(5.0,4.0);

t1.setTriangle();

t1.display();

}

}

}