forked from Debjit21/Hacktoberfest-22
-
Notifications
You must be signed in to change notification settings - Fork 0
/
constructor.java
42 lines (35 loc) · 878 Bytes
/
constructor.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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import java.util.*;
public class constructor
{
double l,b;
String c; static int r;
public constructor()
{
l=0.0;
b=0.0;
c="Sharmistha";
r=5;
}
public void calculate()
{
double area=l*b;
System.out.println("The area is = "+area);
}
public static void cube()
{
double cb=r*r*r;
System.out.println("The cube is = "+cb);
}
public static void main(String args[])
{
Scanner sc= new Scanner(System.in);
constructor ob=new constructor();
System.out.println("Enter the length: ");
ob.l=sc.nextDouble();
System.out.println("Enter the breadth: ");
ob.b=sc.nextDouble();
ob.calculate();
cube();
System.out.println("The name is= "+(ob.c));
}
}