Java Program to Calculate the Surface Area and Volume of Cone

Java program to calculate the surface area and volume of Cone

// Java program to calculate the surface area 
// and volume of Cone

import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner SC = new Scanner(System.in);

    double height = 0;
    double radius = 0;

    double volume = 0;
    double area = 0;

    System.out.printf("Enter the height: ");
    height = SC.nextDouble();

    System.out.printf("Enter the radius: ");
    radius = SC.nextDouble();

    volume = (1.0F / 3) * (3.14F) * radius * radius * height;
    area = (3.14F) * radius * (radius + Math.sqrt(radius * radius + height * height));

    System.out.printf("Volume of Cone 	    : %f\n", volume);
    System.out.printf("Surface area of Cone: %f\n", area);
  }
}

Output

Enter the height: 2.34
Enter the radius: 4.67
Volume of Cone      : 53.414362
Surface area of Cone: 145.075675
Share on:

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Comment