/* * volume.java * * Created on 2 Οκτώβριος 2012, 8:39 πμ */ package students2014; /** * * The purpose of the program is to calculate the volume of a cylinder. Inputa are the cycle radius, height *of the cylinder. Math.PI is used for the value of "π" */ import java.io.*; public class volume { double radius, sur, height, vol; public volume()throws IOException { String choise; InputStreamReader inStream=new InputStreamReader(System.in); BufferedReader stdin=new BufferedReader(inStream); do{ insert(); calculation(); output(); System.out.println(); System.out.print("Another calculation? [y]/[n]"); choise = stdin.readLine(); }while (!choise.equals("n")); } public void insert()throws IOException{ InputStreamReader inStream=new InputStreamReader(System.in); BufferedReader stdin=new BufferedReader(inStream); System.out.print("Give me the radius : "); String data = stdin.readLine(); radius = Double.parseDouble(data); System.out.print("Give me the height : "); data = stdin.readLine(); height = Double.parseDouble(data); } public void calculation(){ sur = Math.PI * (radius * radius); vol = sur * height; } public void output(){ System.out.println("The Surface of the circle is : " + sur); System.out.println("The Volume of the cylinder is : " + vol); } public static void main(String[] args) throws IOException { new volume(); } }