// calulate the side of cone // Math formula: s = sqrt( h^2 + r^2 ) // // Java: s = Math.sqrt( h*h + r*r); // s = Math.sqrt( Math.pow(h, 2.) + Math.pow(r, 2.) ); import java.util.Scanner; import java.text.DecimalFormat; class CalSideofCone { public static void main(String[] args) { Scanner input = new Scanner(System.in); DecimalFormat f2 = new DecimalFormat("0.00"); double radius, height, side; System.out.print("Input radius: "); radius = input.nextDouble(); System.out.print("Input height: "); height = input.nextDouble(); // side = Math.sqrt( height*height + radius*radius); side = Math.sqrt( Math.pow(height, 2.) + Math.pow(radius, 2.) ); System.out.println("side = " + f2.format(side) ); } }