a. Distance: This method takes as its parameters four numbers that represent two
ID: 3543551 • Letter: A
Question
a. Distance: This method takes as its parameters four numbers that represent two points in the plane and returns the distance between them.
b. Radius: This method takes as its parameter four numbers that represent the center and a point on the circle, calls the method distance to find the radius of the circle, and returns the circleâs radius.
c. Circumference: This method takes as its parameter a number that represents the radius of the circle and returns the circleâs circumference. (if r is the radius, the circumference is 2(Pi)r.)
d. Area: This method takes as its parameter a number that represents the radius of the circle and returns the circleâs area. (If r is the radius, the area is (Pi)r^2.)
e. Assume that Pi =3.1416
I already have the radius, circumference, and area. I just need help with adding the distance as an output in the equation
Explanation / Answer
public class NewClass {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int x1,x2,y1,y2;
x1 = s.nextInt();
x2 = s.nextInt();
y1 = s.nextInt();
y2 = s.nextInt();
System.out.println("dis"+new NewClass().distance(x1, x2, y1, y2));
}
public double distance(int x1, int x2, int y1, int y2){
return Math.sqrt((Math.pow((x2-x1), 2) + Math.pow((y2-y1), 2)));
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.