Java program to calculate volume of a Box
By: Paawan Chaudhary
This is a Java program to accomplish following task.
- Create a user-defined package box which has a class definition. For box having data member and disp( )method . (Assume suitable data )
- Source file imports above package and calculates the volume of box .
import java.lang.*;
import java.io.*;
Pacakage BoxPackage
{
public class Box
{
int length, breadth, height;
Box(int I,int b,int h)
{
length=l;
breadth=b;
height=h;
}
public void display()
{
int volume=length*breadth*height;
System.out.println("Volume of Box is"+volume);
}
}
}
import.BoxPackage.*;
class Boxdemo
{
public static void main(string args[])
{
Box b=new Box(10,20,30);
b.display();
}
}
Archived Comments
- Data Science
- Android
- AJAX
- ASP.net
- C
- C++
- C#
- Cocoa
- Cloud Computing
- HTML5
- Java
- Javascript
- JSF
- JSP
- J2ME
- Java Beans
- EJB
- JDBC
- Linux
- Mac OS X
- iPhone
- MySQL
- Office 365
- Perl
- PHP
- Python
- Ruby
- VB.net
- Hibernate
- Struts
- SAP
- Trends
- Tech Reviews
- WebServices
- XML
- Certification
- Interview
categories
Related Tutorials
Java program to get location meta data from an image
Program using concept of byte long short and int in java
Update contents of a file within a jar file
Tomcat and httpd configured in port 8080 and 80
Count number of vowels, consonants and digits in a String in Java
Student marks calculation program in Java
Calculate gross salary in Java
Calculate average sale of the week in Java
Vector in Java - Sample Program