-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCube.java
58 lines (44 loc) · 1.86 KB
/
Cube.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//write a code to display area and volume
//Imports modules
import java.lang.*;
import java.util.*;
public class Cube {
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
int length,breadth,height;
int totalArea,volume;
System.out.println("Enter length, breadth and height: "); //Input from user
//The nextInt() method of Java Scanner class is used to scan the next token of the input as an int.?
length=sc.nextInt();
breadth=sc.nextInt();
height=sc.nextInt();
totalArea=2*(length*breadth+length*height+breadth*height); // Formula for calculating Area of cube
volume=length*breadth*height; //Formula for calculat volume
System.out.println("Total Area: "+totalArea);
System.out.println("Volume: "+volume);
}
}
// ________________________
// /| /|
// / | / |
// /__|___________________ / |
// | | | |
// | | | |
// | |___________________|___|
// Hight - | / | /
// | / | /-Breath
// | / | /
// |/______________________|/
// Length
//
///////////////////Output//////////////////
// Enter length, breadth and height: //
// 5 //
// 6 //
// 8 //
// Total Area: 236 //
// Volume: 240 //
///////////////////////////////////////////
//Thanks You
//Bye