Home Answers Viewqa Java-Beginners Find Cylinder area By inputting value from user

 
 


samar
Find Cylinder area By inputting value from user
1 Answer(s)      2 years and 5 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.

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 Pages:
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
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
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
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.  
BlueJ (area of circle)
/** * Get radius from user * Set area = Math.Pi * radius * radius...BlueJ (area of circle)  How does one write a program to calculate the area of a circle in BlueJ? Note that the user will have to provide the radius
Write a program to calculate area and perimeter of a circle
Write a program to calculate area and perimeter of a circle... example will teach you the method for preparing a program to calculate the area.... As we have to input the value of radius here create a buffered class with an object
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
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
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
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
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
Rel attribute in area tag, Use of rel attribute in area tag.
Rel attribute in area tag, Use of rel attribute in area tag. In this tutorial, you will see the use of rel attribute of area tag and how to implement... page. Rel Attribute : Attribute Value Description
Find Array element from index using GUI
Find Array element from index using GUI In this tutorial, you will learn how to create an GUI application to find an array element from its index... the user to enter an array index in the textfield. The another textfield is defined
JPanel - Drawing Area 2
To find the size of the drawing area Use drawing.getWidth... Java: JPanel - Drawing Area 2   To initialize the panel -- Constructor   You can set the attributes of a panel from method where it's created
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
passing value from javascript popup
passing value from javascript popup  How to take user input and pass that input value using popup in Javascript
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
area of a circle - Java Beginners
area of a circle  Write a class circle which consists of functions getdata() and area(), and also write a main program to create a circle object and to find the area by calling the function area () in circle class and display
MySql Absolute Value
MySql Absolute Value This example illustrates how to find the absolute value of the table. In this example we use abs keywords to find the absolute value...   select emp_value, abs(emp_value) from emp_table
bean area - SQL
bean area  how to print bean area in excel sheet from oracle forms
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
Please find me a solution that
Please find me a solution that   Write a java program that calculates the area of rectangular, square, triangular, and circle. Your program must have the following: Two classes named "Area" and "AreaTest". Class "Area
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
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
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
find largest num enter by user using loop method - Java Interview Questions
find largest num enter by user using loop method  hi..it's me again...(); System.out.println("Enter five value: "); e=in.nextInt(); is it possible to find...); System.out.println("Enter first value: "); a=in.nextInt(); System.out.println("Enter
Insert image from user using and save in database
Insert image from user using and save in database  when i am trying to upload a image from user and trying to save into oracle9i database... description The server encountered an internal error () that prevented it from
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
increamenting the value
increamenting the value  Hi, I am retrieving books name from database and attaching two input tags i.e.One Text area to comment and one checkbox to rate but i am unable to insert the rated n commented rows in database because
How to calculate area of triangle
Area of Triangle       In this section we will learn how to calculate area of triangle. We are going to use area of triangle is half of the area of the parallelogram. Here
JSP User-Agent
illustrate an example from 'JSP User-Agent'. To understand and elaborate the example we... that includes a string variable user Agent. The string variable store the value returned from the request.getHeader( "user-agent").  request.getHeader
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
Validating User in JSP
server for running servlet. Validating user means to find out whether the user... Validating User in JSP       Example program for validating user in JSP In this example we have to develop a JSP
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
select value from autocomplete textbox using jquery in jsp from database.
select value from autocomplete textbox using jquery in jsp from database... the tutorials but was unable to find out exact way to fullfill the solution of selecting value from autocomplete textbox using jquery in jsp from mysql database
select value from autocomplete textbox using jquery in jsp from database.
but was unable to find out exact way to fullfill the solution of selecting value from autocomplete textbox using jquery in jsp from mysql database. Kindly send me...select value from autocomplete textbox using jquery in jsp from database. 
How to calculate area of rectangle
. This method will  return an integer type value, and the area of ... How to Calculate Area of Rectangle       In this section we will learn how to calculate area
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
Write a program for calculating area and perimeter of a rectangle
Write a program for calculating area and perimeter of a rectangle... this lesson, you will be able to write program for calculating the area and perimeter... mechanism helps in detecting user input errors. So before starting the functional
HTML5 <area> href, hreflang attribute of area tag.
;area> tag in html5. href: The href attribute specifies the URL link for the area...; The attribute value refers to the language code, which is two letter... are as follow: href_attribute_of_area_tag.html <!DOCTYPE 
Change the user input to integer
Change the user input to integer   ... an integer value after the compilation of a program and force the JVM to ask... to enter a value in  int primitive type, then we have to use int x
Text Area in HTML
Text Area in HTML       Text  Area in HTML is used to write unlimited number of text in it. Understand with Example The Tutorial illustrate an example from Text Area

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.