Question: import java.text.DecimalFormat; import java.util.Random; public class RightTriangle { public static final double CONSTANT = 2 . 0 ; public static void main ( String [

import java.text.DecimalFormat;
import java.util.Random;
public class RightTriangle {
public static final double CONSTANT =2.0;
public static void main(String[] args){
Random rand = new Random();
double base = rand.nextDouble()*6;
double height = rand.nextDouble()*6;
double hypotenuse = Math.sqrt(Math.pow(base, CONSTANT)+ Math.pow(height, CONSTANT));
DecimalFormat df = new DecimalFormat("0.00");
System.out.println("Base: "+ df.format(base));
System.out.println("Height: "+ df.format(height));
System.out.println("Hypotenuse: "+ df.format(hypotenuse));
}
}
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!