-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBoxDemo.java
27 lines (22 loc) · 903 Bytes
/
BoxDemo.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/*
* Author : JEC21AD041 SACHIN RAJ M
* Date : 27/10/2022 Thursday
* Program No : #17
* Aim: Create a class Box with instance variables length, width, and height. Include a method volume
to compute the volume of the box. Create another class BoxDemo with the main function that
creates an object of class Box named mybox1 and set the values for instance variables
(length, width, and height). Invoke the function volume in Box to compute the volume of the
created object mybox1.
*/
class Box{
int length,breadth,height;
void volume(int l,int b,int h){
System.out.println("The volume of the box = "+(l*b*h)+"cm^3.");
}
}
public class BoxDemo{
public static void main(String[] args) {
Box mybox1 = new Box();
mybox1.volume(10,20,30);
}
}