**Click here to download the complete ISC 2017 Computer Science Paper 2 (Practical).**

**Question:**

A company manufactures packing cartons in four sizes, i.e. cartons to accommodate 6 boxes, 12 boxes, 24 boxes and 48 boxes. Design a program to accept the number of boxes to be packed (N) by the user (maximum up to 1000 boxes) and display the break-up of the cartons used in descending order of capacity (i.e. preference should be given to the highest capacity available, and if boxes left are less than 6, an extra carton of capacity 6 should be used.)

Test your program with the sample data and some random data:

**Example 1**

**INPUT : **N = 726

**OUTPUT : **

48 x 15 = 720

6 x 1 = 6

Remaining boxes = 0

Total number of boxes = 726

Total number of cartons = 16

**Example 2**

**INPUT : **N = 140

**OUTPUT : **

48 X 2 = 96

24 x 1 = 24

12 x 1 = 12

6 x 1 = 6

Remaining boxes 2 x 1 = 2

Total number of boxes = 140

Total number of cartons = 6

**Example 3**

**INPUT :** N = 4296

**OUTPUT :** INVALID LENGTH

**Programming Code:**

/** * The class BoxPacking_ISC2017 inputs number of boxes to be packed * and display the break-up of the cartons used in descending order of capacity * @author : www.guideforschool.com * @Program Type : BlueJ Program - Java * @Question Year : ISC Practical 2017 Question 1 */ import java.util.*; class BoxPacking_ISC2017 { public static void main(String args[]) { Scanner sc = new Scanner(System.in); System.out.print("Enter number of boxes to be packed : "); int N = sc.nextInt(); if(N<1 || N > 1000) { System.out.println("INVALID INPUT"); } else { int cart[] = {48, 24, 12, 6}; int copy = N; int totalCart = 0,count = 0; System.out.println("OUTPUT :"); for(int i=0; i<4; i++) { count = N / cart[i]; if(count!=0) { System.out.println("\t"+cart[i]+"\tx\t"+count+"\t= "+cart[i]*count); } totalCart = totalCart + count; N = N % cart[i]; } if(N>0) { System.out.println("\tRemaining Boxes "+N+" x 1 = "+N); totalCart = totalCart + 1; } else { System.out.println("\tRemaining Boxes\t\t= 0"); } System.out.println("\tTotal number of boxes = "+copy); System.out.println("\tTotal number of cartons = "+totalCart); } } }

**Output:**

Enter number of boxes to be packed : 815 OUTPUT : 48 x 16 = 768 24 x 1 = 24 12 x 1 = 12 6 x 1 = 6 Remaining Boxes 5 x 1 = 5 Total number of boxes = 815 Total number of cartons = 20

Sir by mistake i have written one statement in wrong place but in printout it is correct will there be any deduction of marks and if then how much my output iss correct

No marks will be deducted