Senin, 27 September 2010

membuat subrutin (java)

import java.io.*;
public class balok
{
private static BufferedReader stdin=new BufferedReader (new InputStreamReader(System.in));
static double balok (int x, int y, int z)
{
double vol;
vol = x*y*z;
System.out.println(" Volume Balok = "+vol);
return 0;
}
public static void main(String[]args)throws Exception
{
System.out.println("Menghitung Volume Balok"); 
System.out.println("_____________");
System.out.print("Masukkan Panjang = ");
String Input1=stdin.readLine();
int p=Integer.parseInt(Input1);
System.out.print("Masukkan Lebar = ");
String Input2=stdin.readLine();
int l=Integer.parseInt(Input2);
System.out.print("Masukkan Tinggi = ");
String Input3=stdin.readLine();
int t=Integer.parseInt(Input3);
System.out.println();
balok (p,l,t);
}
}

Tidak ada komentar:

Posting Komentar