{"id":1983,"date":"2019-03-01T06:24:00","date_gmt":"2019-03-01T06:24:00","guid":{"rendered":"https:\/\/www.testingdocs.com\/questions\/?p=1983"},"modified":"2024-08-08T21:03:07","modified_gmt":"2024-08-08T21:03:07","slug":"volume-of-a-cylinder-java-program","status":"publish","type":"post","link":"https:\/\/www.testingdocs.com\/questions\/volume-of-a-cylinder-java-program\/","title":{"rendered":"Volume of a Cylinder Java Program [ 2024 ]"},"content":{"rendered":"<h1>Volume of a Cylinder Java Program<\/h1>\r\n<p>In this post, we will write a Java program to calculate the volume of the Cylinder.<\/p>\r\n<h3>IPO Chart<\/h3>\r\n<p>Let&#8217;s design the IPO chart for the program.<\/p>\r\n<h3>Input<\/h3>\r\n<p>r &#8211; Radius of the cylinder.<\/p>\r\n<p>h = Height of the cylinder.<\/p>\r\n<h3>Process<\/h3>\r\n<p>Formula to calculate the volume of cylinder\u00a0 <strong>V<\/strong> =\u00a0\u00a0\u03c0\u00a0*\u2009r2\u00a0*\u00a0h<\/p>\r\n<h3>Output<\/h3>\r\n<p>The volume of the Cylinder<\/p>\r\n<p>&nbsp;<\/p>\r\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-1984 size-full\" title=\"Volume of a Cylinder\" src=\"https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Volume-of-Cylinder.png\" alt=\"Volume of a Cylinder\" width=\"1707\" height=\"868\" srcset=\"https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Volume-of-Cylinder.png 1707w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Volume-of-Cylinder-300x153.png 300w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Volume-of-Cylinder-1024x521.png 1024w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Volume-of-Cylinder-768x391.png 768w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Volume-of-Cylinder-1536x781.png 1536w\" sizes=\"auto, (max-width: 1707px) 100vw, 1707px\" \/><\/p>\r\n<h3>Tools Used<\/h3>\r\n<p>We will use the below tools to develop the program.\u00a0<\/p>\r\n<ul>\r\n<li>JDK ( Java Development Kit)<\/li>\r\n<li>Eclipse IDE( Integrated Development Environment)\u00a0<\/li>\r\n<\/ul>\r\n<h2>Eclipse IDE<\/h2>\r\n<p>Some steps and instructions to create a Java application on Eclipse IDE:<\/p>\r\n<ul>\r\n<li>Create Java Project in Eclipse<\/li>\r\n<\/ul>\r\n<p><a href=\"https:\/\/www.testingdocs.com\/create-a-new-java-project-in-eclipse\/\">https:\/\/www.testingdocs.com\/create-a-new-java-project-in-eclipse\/<\/a><\/p>\r\n<ul>\r\n<li>Create Java Package in Eclipse<\/li>\r\n<\/ul>\r\n<p><a href=\"https:\/\/www.testingdocs.com\/create-java-package-in-eclipse-ide\/\">https:\/\/www.testingdocs.com\/create-java-package-in-eclipse-ide\/<\/a><\/p>\r\n<ul>\r\n<li>Create Java Class in Eclipse<\/li>\r\n<\/ul>\r\n<p><a href=\"https:\/\/www.testingdocs.com\/create-a-new-java-class-in-a-project\/\">https:\/\/www.testingdocs.com\/create-a-new-java-class-in-a-project\/<\/a><\/p>\r\n<ul>\r\n<li>Run Java Project in Eclipse<\/li>\r\n<\/ul>\r\n<p><a href=\"https:\/\/www.testingdocs.com\/run-java-project-in-eclipse\/\">https:\/\/www.testingdocs.com\/run-java-project-in-eclipse\/<\/a><\/p>\r\n<h2>Java Program<\/h2>\r\n<p>The program prompts the user to enter the height and the radius of the cylinder. The program uses the Scanner class to read the values from the keyboard. The variables are declared as <strong>double<\/strong> data types.\u00a0<\/p>\r\n<p>The program calculates the volume as per the mathematical formula and displays the result to the screen.\u00a0<\/p>\r\n<p><strong>Steps<\/strong><\/p>\r\n<p>Launch IDE and create a Java class.<\/p>\r\n<p>Enter the program code.\u00a0<\/p>\r\n<pre>\/**************************************************<br \/> * CylinderVolume.java<br \/> * @program    : Program to calculate the Cylinder volume. <br \/> * @web            : www.TestingDocs.com<br \/> * @version     : 1.0<br \/> **************************************************\/<br \/>import java.util.Scanner;<br \/><br \/>public class CylinderVolume {<br \/><br \/>    public static void main(String[] args) {<br \/>        \/\/ scanner object variable used in the program<br \/>        Scanner keyboard = new Scanner(System.in);<br \/><br \/>        \/\/Input<br \/>        System.out.println(\"Enter Height of the cylinder :=\");<br \/>        double height = keyboard.nextDouble();<br \/><br \/>        System.out.println(\"Enter radius of the cylinder :=\");<br \/>        double radius = keyboard.nextDouble();<br \/><br \/>        \/\/ Process -Calculation<br \/>        double volume=Math.PI*(radius*radius)*height;<br \/><br \/>        \/\/ Output<br \/>        System.out.println(\"Volume of the cylinder=\"+volume);<br \/><br \/>    }<br \/>}<\/pre>\r\n<h2>Screenshot<\/h2>\r\n<p>Screenshot the code in Eclipse IDE.<\/p>\r\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-1986 size-full\" src=\"https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Cylinder-Volume-Java-Program.png\" alt=\"\" width=\"1744\" height=\"1026\" title=\"\" srcset=\"https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Cylinder-Volume-Java-Program.png 1744w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Cylinder-Volume-Java-Program-300x176.png 300w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Cylinder-Volume-Java-Program-1024x602.png 1024w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Cylinder-Volume-Java-Program-768x452.png 768w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Cylinder-Volume-Java-Program-1536x904.png 1536w\" sizes=\"auto, (max-width: 1744px) 100vw, 1744px\" \/><\/p>\r\n<p>&nbsp;<\/p>\r\n<p>Save and Run the program from the IDE. Execute some test cases to verify the output of the program.\u00a0 Right Click and choose <strong>Run as &gt;&gt; Java Application<\/strong><\/p>\r\n<h2>Sample Output<\/h2>\r\n<p>Enter Height of the cylinder :=<br \/>5.5<br \/>Enter radius of the cylinder :=<br \/>3.5<br \/>Volume of the cylinder=211.6648050356123<\/p>\r\n<p>&nbsp;<\/p>\r\n<p>&#8212;<\/p>\r\n<h2>Java Tutorials<\/h2>\r\n<p>Java Tutorial on this website:<\/p>\r\n<p><a href=\"https:\/\/www.testingdocs.com\/java-tutorial\/\">https:\/\/www.testingdocs.com\/java-tutorial\/<\/a><\/p>\r\n<p><br \/>For more information on Java, visit the official website :<\/p>\r\n<p><a href=\"https:\/\/www.oracle.com\/in\/java\/\" rel=\"noopener\">https:\/\/www.oracle.com\/in\/java\/<\/a><\/p>\r\n","protected":false},"excerpt":{"rendered":"<p>Volume of a Cylinder Java Program : In this post, we will write a Java program to calculate the volume of the Cylinder.<\/p>\n<p>IPO Chart : Let&#8217;s design the IPO chart for the program.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[],"class_list":["post-1983","post","type-post","status-publish","format-standard","hentry","category-java-programs","has-post-title","has-post-date","has-post-category","has-post-tag","has-post-comment","has-post-author",""],"_links":{"self":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/1983","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/comments?post=1983"}],"version-history":[{"count":14,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/1983\/revisions"}],"predecessor-version":[{"id":23576,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/1983\/revisions\/23576"}],"wp:attachment":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/media?parent=1983"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/categories?post=1983"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/tags?post=1983"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}