-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBoxes.java
More file actions
67 lines (65 loc) · 1.39 KB
/
Copy pathBoxes.java
File metadata and controls
67 lines (65 loc) · 1.39 KB
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
59
60
61
62
63
64
65
66
67
import java .util. *;
class Boxes
{
int box;
int count;
int sum=0;
Boxes(int n)
{
box=n;
count=0;
}
public void find()
{
if(box>48)
{
while(box>48)
{
box=box-48;
count++;
}
while(box>0)
{
sum=0;
if(box>24)
{
while(box>24)
{
box=box-24;
count++;
}
}
else if(box>12)
{
while(box>12)
{
box=box-12;
count++;
}
}
else if(box>6)
{
while(box>6)
{
box=box-6;
count++;
}
}
else
{
count++;
box=0;
}
}
}
}
public static void main()
{
Scanner Sc=new Scanner (System.in);
System.out.println("Enter the Number of Boxes");
int n=Sc.nextInt();
Boxes ob=new Boxes(n);
ob.find();
System.out.println("Total Cartons:: "+ob.count);
}
}