import java.util.Scanner; import java.text.DecimalFormat; class ConeandCylinderSurfaceAreaandVolume1 { public static void main(String[] args) { Scanner input = new Scanner(System.in); DecimalFormat f2 =new DecimalFormat("0.00"); double radius1,height1,num1,num2; System.out.print("Input the radius: "); radius1 = input.nextDouble(); System.out.print("Input the height: "); height1 = input.nextDouble(); System.out.print("Do you want the area & volume of the Cone type 1 (2 for Cyliner): "); num1 = input.nextDouble(); if(num1 == 1) { double conearea = (Math.PI*radius1)*(radius1+Math.sqrt(Math.pow(height1,2.0)+Math.pow(radius1,2.0))); double conevolume = Math.PI*(radius1*radius1)*(height1/3.0); System.out.println("\nThe Surface Area of the Cone is " + f2.format(conearea)+"\n"); System.out.println("The Volume of the Cone is " + f2.format(conevolume)+"\n"); } else if (num1 == 2) { double cylinderarea = 2.0*(Math.PI*radius1*height1)+2.0*(Math.PI*radius1*radius1); double cylindervolume = Math.PI*(radius1*radius1)*height1; System.out.println("\nThe Surface Area of the Cylinder is " + f2.format(cylinderarea)+"\n"); System.out.println("The Volume of the Cylinder is " + f2.format(cylindervolume)+"\n"); } else System.out.println("Error. \n\n\n"); } }