Program to calculate Volume, Curved Surface Area and Total Surface Area of Cone in Java
Output of the program :
package com.hubberspot.mensuration.example; import java.util.Scanner; public class Cone { public static void main(String[] args) { Scanner input = new Scanner(System.in); double radius = 0; double height = 0; double slantHeight = 0; double volume = 0; double curvedSurfaceArea = 0; double totalSurfaceArea = 0; System.out.print("Enter the radius of base of Cone : "); radius = input.nextDouble(); System.out.print("Enter the height of Cone : "); height = input.nextDouble(); volume = (Math.PI * radius * radius * height) / 3; slantHeight = Math.sqrt(height * height + radius * radius); curvedSurfaceArea = (Math.PI * radius * slantHeight); totalSurfaceArea = Math.PI * radius * (radius + slantHeight); System.out.println(""); System.out.println("The Slant height of Cone is : " + slantHeight); System.out.println("The Volume of Cone is : " + volume); System.out.println("The Curved Surface Area of Cone is : " + curvedSurfaceArea); System.out.println("The Total Surface Area of Cone is : " + totalSurfaceArea); } }
Output of the program :