68 760
Assignments Done
Successfully Done
In January 2019

Answer to Question #58407 in Java | JSP | JSF for Nic

Question #58407
Create a Right Triangle class given the following design:
Class RightTriangle
base, height
setBase – changes the base. Requires one parameter for the base
setHeight – changes the height. Requires one parameter for the height
getBase – returns the triangle base
getHeight – returns the triangle height
area – returns the area of the triangle (A = 1
/2 * b * h) given the current base and height.
Write an appropriate class / application that will test the RightTriangle class.
Expert's answer
package righttriangle;

public class Test {
* @param args the command line arguments
public static void main(String[] args) {
RightTriangle triangle = new RightTriangle();
System.out.println("Area: " + triangle.area());
package righttriangle;

public class RightTriangle {

private double base;
private double height;

public void setBase(double base) {
this.base = base;

public void setHeight(double height) {
this.height = height;

public double getBase() {
return base;

public double getHeight() {
return height;

public double area(){
return base*height/2;



Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!


No comments. Be first!

Leave a comment

Ask Your question

Privacy policy Terms and Conditions