subject

I would like assistance regarding this Java Edhesive Assignment. Create a class RightTriangle which implements the API exactly as described in the following Javadoc.

Don't forget - you will need to use the Pythagorean theorem to find the hypotenuse (and therefore the perimeter) of a right triangle. You can find the area of a right triangle by multiplying the base and height together, then dividing this product by 2.

Use the runner_RightTriangle file to test the methods in your class; do not add a main method to your RightTriangle class.

Hint 1 - Javadoc only shows public methods, variables and constructors. You will need to add some private member variables to your RightTriangle class to store the necessary information. Think carefully about what information actually needs to be stored and how this will need to be updated when methods change the state of a RightTriangle object.

Hint 2 - As in the previous lesson's exercise it's helpful to add your method/constructor headers and any dummy returns needed before implementing each one properly. This will allow you to test your code using the runner class as you go along.

Runner Code:
import java. util. Scanner;

public class runner_RightTriangle{
public static void main(String[] args){
Scanner scan = new Scanner(System. in);
RightTriangle t = new RightTriangle();
String instruction = "";
while(!instruction. equals("q")){
System. out. println("Type the name of the method to test. Type c to construct a new triangle, q to quit.");
instruction = scan. nextLine();
if(instruction. equals("getArea")){
System. out. println(t. getArea());
}
else if(instruction. equals("getBase")){
System. out. println(t. getBase());
}
else if(instruction. equals("getHeight")){
System. out. println(t. getHeight());
}
else if(instruction. equals("getHypotenuse")){
System. out. println(t. getHypotenuse());
}
else if(instruction. equals("getPerimeter")){
System. out. println(t. getPerimeter());
}
else if(instruction. equals("toString")){
System. out. println(t);
}
else if(instruction. equals("setBase")){
System. out. println("Enter parameter value:");
double arg = scan. nextDouble();
t. setBase(arg);
scan. nextLine();
}
else if(instruction. equals("setHeight")){
System. out. println("Enter parameter value:");
double arg = scan. nextDouble();
t. setHeight(arg);
scan. nextLine();
}
else if(instruction. equals("equals")){
System. out. println("Enter base and height:");
double bs = scan. nextDouble();
double ht = scan. nextDouble();
RightTriangle tOther = new RightTriangle(bs, ht);
System. out. println(t. equals(tOther));
scan. nextLine();
}
else if(instruction. equals("c")){
System. out. println("Enter base and height:");
double bs = scan. nextDouble();
double ht = scan. nextDouble();
t = new RightTriangle(bs, ht);
scan. nextLine();
}
else if(!instruction. equals("q")){
System. out. println("Not recognized.");
}
}
}
}

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 23:30
What is the digital revolution and how did it change society? what are the benefits of digital media?
Answers: 1
question
Computers and Technology, 23.06.2019 06:30
You are consulting for a beverage distributor who is interested in determining the benefits it could achieve from implementing new information systems. what will you advise as the first step?
Answers: 1
question
Computers and Technology, 23.06.2019 18:50
What is transmission control protocol/internet protocol (tcp/ip)? software that prevents direct communication between a sending and receiving computer and is used to monitor packets for security reasons a standard that specifies the format of data as well as the rules to be followed during transmission a simple network protocol that allows the transfer of files between two computers on the internet a standard internet protocol that provides the technical foundation for the public internet as well as for large numbers of private networks
Answers: 2
question
Computers and Technology, 24.06.2019 15:30
George is working as a programming team lead. which statements correctly describe the skills that he requires?
Answers: 3
You know the right answer?
I would like assistance regarding this Java Edhesive Assignment. Create a class RightTriangle which...
Questions
question
Mathematics, 24.12.2020 21:20
question
History, 24.12.2020 21:20
question
Mathematics, 24.12.2020 21:20