samar
Find Cylinder area By inputting value from user
1 Answer(s)      4 years and 6 months ago
Posted in : Java Beginners

Hello Sir

I need the code for calculating the area of a cylinder in which it asks radius value from user and then calculate area using this radius value.

Please provide me complete code.

Hope you will not disappoint me.

Advertisement
View Answers

December 14, 2010 at 6:37 PM


Dear friend

The code given below is according to your description :

import java.util.Scanner;
import java.text.*;

       public class cylinderVolume
       {
         public static void main(String []args)
         {

         double radius, area, pi=3.14;          

         welcomeMessage();   

         radius = receiveRadius();

         area = computeArea(radius);

         outputMessage(area);
         }


         public static void welcomeMessage
         {
             System.out.println("Welcome to my program! ");
             System.out.println("This program will compute the area of a cylinder ");
         }

         public static double receiveRadius()
         {

              Scanner input = new Scanner(System.in);
              double radius;
              System.out.print("Please enter a radius: ");
              radius = input.nextDouble();
              return radius;
         }
            public static double computeArea(double radius)
            {
              double area, pi=3.14;
              area = pi * radius * radius;
              return area;
            }

            public static void outputMessage(double a)
              {
               DecimalFormat num = new DecimalFormat("##.00");
               System.out.println("The area is " + num.format);
            }
         }









Related Tutorials/Questions & Answers:
Find Cylinder area By inputting value from user
Find Cylinder area By inputting value from user  Hello Sir I need the code for calculating the area of a cylinder in which it asks radius value from user and then calculate area using this radius value. Please provide me
Find max and min value from Arraylist
Find max and min value from Arraylist In this tutorial, you will learn how to find the maximum and minimum value element from the ArrayList. Java provides direct methods to get maximum and minimum value from any collection class i.e
Advertisements
find largest value
find largest value  (Assignment 1 - LargestValue)The process of finding the largest value (i.e., the maximum of a group of values) is used frequently... recently input by the user. c. largest: The largest number found so far.  
Find Value of Column
Find Value of Column       In this program we are going to find the value of row from...: getRow(): This method is used to get the row from cell. getColumn
how to find which user has modified the file
how to find which user has modified the file  how to find which user has modified the file
MySQL Area
MySQL Area       This example illustrates how to find the area of rectangle in MySQL. In this example we create a procedure to find the area of rectangle. In the query below we take
MySQL Area
MySQL Area  This example illustrates how to find the area of rectangle in MySQL. In this example we create a procedure to find the area of rectangle... value 5 and 4 respectively. By calling the procedure we can run the procedure
How to find maximum value in ArrayList
How to find maximum value in ArrayList  **Sir i am writing below code but its not working.i don't know how to implement logic my requirement.My requirement is find maximum value in userdefined objects and dispaly that object
How to find maximum value in ArrayList
How to find maximum value in ArrayList  **Sir i am writing below code but its not working.i don't know how to implement logic my requirement.My requirement is find maximum value in userdefined objects and dispaly that object
How to find maximum value in ArrayList
How to find maximum value in ArrayList  **Sir i am writing below code but its not working.i don't know how to implement logic my requirement.My requirement is find maximum value in userdefined objects and dispaly that object
How to find maximum value in ArrayList
How to find maximum value in ArrayList  **Sir i am writing below code but its not working.i don't know how to implement logic my requirement.My requirement is find maximum value in userdefined objects and dispaly that object
cylinder tree structure
cylinder tree structure  **hi am trying to develop a visualization of learning repository content by classifying courses, subjects and learning materials in a hierarchical structure in a cylinder form. for example my interface
to read number from user
to read number from user  1)print the positive equivalent of the number 2) check if the no is integer or not 3) find the square root of the number 4) find the cube of the number
error in taking input from user.
error in taking input from user.  //i m having problem inputting the array from user.my program is import java.io.*; class bubble { public static void main(String args[]) { int a[]=new int[20]; int i=0; BufferedReader br=new
accept integer from user
accept integer from user  Write an Java application that accepts 100 integer numbers from a user. The input should be in the range of 1-200. Error message needs to be displayed if user entered input which is not in this range
How to find out the friend user between two columns in sql database
How to find out the friend user between two columns in sql database  Hi, Can any one please tell me ..how to find out the friend user between two columns in sql database? In other words i wanted to get the corresponding data from
Generate area for map from backing bean - Java Server Faces Questions
Generate area for map from backing bean  I need to populate the map in my page, and the coordinates should come from the backing bean.. How could I do
How to find maximum value for userdefined objects in ArrayList
How to find maximum value for userdefined objects in ArrayList  Hi sir,I have requirement i.e finding maximum value in userdefined objects... value but can't store that object into another object.Please help me how
How to find maximum value for userdefined objects in ArrayList
How to find maximum value for userdefined objects in ArrayList  Hi sir,I have requirement i.e finding maximum value in userdefined objects... value but can't store that object into another object.Please help me how
How to find maximum value for userdefined objects in ArrayList
How to find maximum value for userdefined objects in ArrayList  Hi sir,I have requirement i.e finding maximum value in userdefined objects... value but can't store that object into another object.Please help me how
Write a Java applet to draw cylinder and pentagon shapes.
Write a Java applet to draw cylinder and pentagon shapes.  Write a Java applet to draw cylinder and pentagon shapes
passing value from javascript popup
passing value from javascript popup  How to take user input and pass that input value using popup in Javascript
Reading Value From console
Reading Value From console  In case of String data Type readLine method of DataInputStream class read complete line of the given string but the next method of Scanner class doesn't read the complete line of String. why
Reading Value From console
Reading Value From console  In case of String data Type readLine method of DataInputStream class read complete line of the given string but the next method of Scanner class doesn't read the complete line of String. why
Find User Home Directory
Find User Home Directory        In this example we are find user home directory. We..." as key to get the user define home directory
find the largest number enter by user - Java Interview Questions
find the largest number enter by user  sorry for not stating clearly my question. i want to know how to find the largest number enter by user... value: "); a=in.nextInt(); System.out.println("Enter second value
returning a value from Threads
returning a value from Threads  Hello I have worker pattern that uses ExecutorService to schedule Thread execution but getting stuck at some point when returning a value using Future.I have code snippet below: ExecutorService
java preferences,Change the value of Preferences by user
Change the value of Preferences by user   ... a user change the preferences value by the user value. Here we are going to make... the value will show the user value when you run it second time. If we consider
Retrieve Value from Table - Hibernate
Retrieve Value from Table   Hai friend, I need help, How can i retrieve values From database using hibernate in web Application. As I new to hibernate I couldn't find solution for this problem.. Can anyone help please.. 
Retrieving attribute value from XML
Retrieving attribute value from XML  I have an XML as below to parse...; ..... But am not able to fetch the value of LoadTicketId attribute. My code... was able to find the error. I was treating attribute as an element. No more response
how to find [count the number of integers whose value is less than the average value of the integers]
how to find [count the number of integers whose value is less than the average value of the integers]  Construct an algorithm that will prompt... amount to the screen integers from an operator at a terminal, and count the number