IF/ELSE confusion

answered. Thank you.
Last edited on
anyone please?
closed account (E3h7X9L8)
Im assuming you dont know what arrays are and im assuming in variable containers you store your shipment , this is a simple code for beginners(sorry for bad format)

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

int hugeCounter = 0, //counters that count how many countainers were used
     largeCounter = 0,
     mediumCounter = 0,
     smallCounter = 0;

while(containers != 0) //loop till there is nothing in container
{
if(containers >= 50) // if its larger than a huge container then
{
containers -= 50; //substract from containers
hugeCounter++; //gratz you filled 1 huge container
}

if(containers >= 20)
{
containers -= 20;
largeCounter++;
}

if(containers >= medium)
{
containers -= 5;
mediumCounter++;
}

if(containers >= small)
{
containers -= 1;
smallCounter++;
}

}

now you just have to display your containers counters

Last edited on
Topic archived. No new replies allowed.