Cylinder Volume

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

cylinderVolume

/* Filename: "cylinderVolume.java"
* Purpose: to compute the volume of a cylinder based on user input
*
* Created by 1,000_naymes
* Summer semester, 2007
*
*/
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);
}
}

Page 1

You might also like