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);
            }
         }

Ads









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
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
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
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
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
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
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
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
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
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
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
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
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
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

Ads