public class Volumecube
{
public static void main(String [] s)
{
int j=Integer.parseInt(s[0]);
int vol;
vol=j*j*j;
System.out.println();
System.out.println("The volume of cube of side "+s[0]+" is"+" "+ vol);
}
}
Thursday, February 26, 2009
java code to find volume of a cube
Wednesday, February 25, 2009
Sample java code for Calculator
import java.io.*;
public class Calculus
{
public static void main(String []w) throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter The First Integer :- ");
String x=br.readLine();
int y=Integer.parseInt(x);
System.out.println();
System.out.print("Enter The Second Integer:- ");
x=br.readLine();
int z=Integer.parseInt(x);
System.out.println();
System.out.println("Enter Your Choice");
System.out.println();
System.out.println("1.Addition");
System.out.println("2.Substraction");
System.out.println("3.Multiplication");
System.out.println("4.Division");
x=br.readLine();
int choice=Integer.parseInt(x);
switch (choice)
{
case 1:
System.out.println(y+"+"+z+"="+(y+z));
break;
case 2:
System.out.println(y+"-"+z+"="+(y-z));
break;
case 3:
System.out.println(y+"x"+z+"="+(y*z));
break;
case 4:
System.out.println(y+"/"+z+"="+(y/z));
break;
default:System.out.println("Enter listed choices....");
}
}
}