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 complete code.

Hope you will not disappoint me.

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 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
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.  
passing value from javascript popup
passing value from javascript popup  How to take user input and pass that input value using popup in Javascript
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
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
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
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
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
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
ModuleNotFoundError: No module named 'find-ida-user-dir'
ModuleNotFoundError: No module named 'find-ida-user-dir'  Hi, My... named 'find-ida-user-dir' How to remove the ModuleNotFoundError: No module named 'find-ida-user-dir' error? Thanks   Hi, In your
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
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
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
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
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
Subtract a value in the database from java
Subtract a value in the database from java   Hi, i want to know how to subtract a value on a database. im using JDBC connection from access and i want to decrement the value of table "quantity" of 1 each time it passes a loop my
Read the value from XML in java
Read the value from XML in java  Hi, i have an XML... the permissions on that file.So how can i read that value. This is little urgent.... <param name="file" value="D:/Lakki
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...; I was able to find the error. I was treating attribute as an element
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
Return Value from One Form
Return Value from One Form  I have two buttons in main form client and bank.when i click client button new form will open, in this dedupe button... value of dedupe form and use in bank form..how to do
export value in csv from jsp
export value in csv from jsp  Hi! i have creted a html form using javascript. i hv taken the array values in jsp. nw i want to pass these array values from jsp to csv file. so please help me how to send
Fetch user records from a table in database
Fetch user records from a table in database  Hi. I have a field...,trichy,kanchipuram for a single record. I have to retrieve these data from... as single values like chennai as one value, trichy as one value. and i have to show
check radio button on retrieving the value from database.
check radio button on retrieving the value from database.  HI i am new to jsp.In my applcation i having a problem. I am retrieving user payment from... checked.If user has done payment through cash then when i am retrieving user
store value in checkbox from gridview
store value in checkbox from gridview  Please check the error... = con.createStatement(); rst=st.executeQuery("select * from books...; <input type="submit" value=" DELETE "/>&nbsp;&nbsp
value in div from php, reloading form
value in div from php, reloading form  I am having one form with name...="user" name="user" value="<?php echo $username?>" required></td> <...']); $check_for_username = mysql_query("SELECT user from userpage WHERE user
Find a missing element from array
Find a missing element from array We have two arrays A and B where B consists of all the elements that are present in A but one element is missing from the array B. From these two arrays, we have to find the missing element from
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
How to pass value from dijit.Tree to dijit.MenuItem - Ajax
How to pass value from dijit.Tree to dijit.MenuItem  Hi Friends, I... and when user will clik on that menu, the value should be shown like Delete Instead of 'Test' I want to show the value of that Node( which is comming from TreeNode
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
Find Exact Location from IP address in java?
Find Exact Location from IP address in java?  I am looking for API where we can pass IP address and get the location (Cityname,Country name). please suggest any API OR sample code. Thank you
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
Return Value From Event - Java Beginners
Return Value From Event  I would like to call a method that returns a value after an event has occurred and the value is determined by the event or listener. eg: public int mymethod() { static int value=0; KeyAdapter
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
code for insert the value from jsp to access database
code for insert the value from jsp to access database  code for insert the value from jsp to access database
related retrieving value from oracle database
related retrieving value from oracle database  how we get the value from database in the given textbox
related retrieving value from oracle database
related retrieving value from oracle database  how we get the value from database in the given textbox
Getting environment variable value from java
Getting environment variable value from java  Getting environment variable value from java
ModuleNotFoundError: No module named 'cylinder_fitting'
ModuleNotFoundError: No module named 'cylinder_fitting'  Hi, My... named 'cylinder_fitting' How to remove the ModuleNotFoundError: No module named 'cylinder_fitting' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'cylinder_fitting'
ModuleNotFoundError: No module named 'cylinder_fitting'  Hi, My... named 'cylinder_fitting' How to remove the ModuleNotFoundError: No module named 'cylinder_fitting' error? Thanks   Hi, In your
Find Second Largest Number from an Array
Find Second Largest Number from an Array This section illustrates you how to find the second largest number from an array. For this purpose, we have allowed the user to enter the array elements of their choice and determine the largest
Retrieving value from multiple table in database
Retrieving value from multiple table in database  Hi fnds, I want... want to calculate the balance of individual users.. for eg, for the user A, let the balance at month1 is 1000... if the user A balance at month2 is 2000, i want

Ads