Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



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

Have Programming Question? Ask it here!
 
 
 


samar
Find Cylinder area By inputting value from user
1 Answer(s)      3 years and 7 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... 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
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
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
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
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
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
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
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
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
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
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
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
calculate volume of cube, cylinder and rectangular box using method overloading in java
calculate volume of cube, cylinder and rectangular box using method overloading in java  calculate volume of cube, cylinder and rectangular box using method overloading in java   calculate volume of cube, cylinder
How to hide HTML code from user? - Security
How to hide HTML code from user?  Hi All, I am trying to provide security to my web application. To achieve this I want to restrict user from... through the use of DOM loading the data from another javascript file
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
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
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
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. 
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
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
A Program to find area and perimeter of Rectangle
A Program to find area and perimeter of Rectangle In this section we will explain you with the help of a program to find the area and perimeter of  a rectangle. To find area and perimeter of a rectangle is a simple program
 

 

 

DMCA.com