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 10:00
Jackson is teaching the decimal number system. he wants his students to know how to expand numbers by powers of 10. which is the correct order in which digits are assigned values in the decimal number system?
Answers: 1
question
Computers and Technology, 22.06.2019 16:10
Drag each label to the correct location on the imagelist the do’s and don’ts of safeguarding your password.keep yourself loggedin when you leave your computer.don’t write your password down and leave it whereothers can find it.share your password with your friends.each time you visit a website,retain the cookies on your computer.use a long password with mixed characters.
Answers: 1
question
Computers and Technology, 22.06.2019 19:30
When using a public computer or network, you should always
Answers: 2
question
Computers and Technology, 23.06.2019 01:30
In deadlock avoidance using banker’s algorithm, what would be the consequence(s) of: (i) a process declaring its maximum need as maximum possible for each resource. in other words, if a resource a has 5 instances, then each process declares its maximum need as 5. (ii) a process declaring its minimum needs as maximum needs. for example, a process may need 2-5 instances of resource a. but it declares its maximum need as 2.
Answers: 3
You know the right answer?
I would like assistance regarding this Java Edhesive Assignment. Create a class RightTriangle which...
Questions
question
Mathematics, 09.01.2020 22:31
question
Chemistry, 09.01.2020 22:31
Questions on the website: 13722363