Navbar

Friday, 15 February 2019

ISC COMPUTER PRACTICAL 2017 SOLVED


ISC 2017 Computer Practical Paper Solved – 

15-FEB-2019

Question 1:


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



import java.util.*;
class BoxPacking
{
    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

****END****************************


Question 2:


The result of a quiz competition is to be prepared as follows: The quiz has five questions with four multiple choices (A, B, C, D),
with each question carrying 1 mark for the correct answer.

Design a program to accept the number of participants N such that N
must be greater than 3 and less than 11.
Create a double dimensional array of size (Nx5) to store the answers
of each participant row-wise. Calculate the marks for each participant by matching the correct answer
stored in a single dimensional array of size 5.

Display the scores for each participant and also the participant(s)
having the highest score. Example: If the value of N = 4, then the array would be:



Note: Array entries are line fed (i.e. one entry per line) Test your program with the sample data and some random data: Example 1 INPUT : N = 5 Participant 1 D A B C C Participant 2 A A D C B Participant 3 B A C D B Participant 4 D A D C B Participant 5 B C A D D Key: B C D A A OUTPUT : Scores : Participant 1 D A B C C Participant 1 = 0 Participant 2 = 1 Participant 3 = 1 Participant 4 = 1 Participant 5 = 2 Highest score: Participant 5 Example 2 INPUT : N = 4 Participant 1 A C C B D Participant 2 B C A A C Participant 3 B C B A A Participant 4 C C D D B Key: A C D B B OUTPUT : Scores : Participant 1 = 3 Participant 2 = 1 Participant 3 = 1 Participant 4 = 3 Highest score: Participant 1 Participant 4 Example 3 INPUT : N = 12 OUTPUT : INPUT SIZE OUT OF RANGE.

Solution:

import java.util.*; class Quiz { char A[][],K[]; int S[],n; void input() { Scanner sc = new Scanner(System.in); System.out.print("Enter number of participants : "); n = sc.nextInt(); if(n<4 || n>10) { System.out.println("INPUT SIZE OUT OF RANGE"); System.exit(0); } A = new char[n][5]; // Array to store the answers of every participants K = new char[5]; // Array to store answer key S = new int[n]; // Array to store score of every participant System.out.println("\n* Enter answer of each participant row-wise in a single line *\n"); for(int i = 0; i<n; i++) { System.out.print("Participant "+(i+1)+" : "); for(int j=0; j<5; j++) { A[i][j] = sc.next().charAt(0); } } System.out.print("\nEnter Answer Key : "); for(int i = 0; i<5; i++) { K[i] = sc.next().charAt(0); } } void CalcScore() // Function to calculate score of every participant { for(int i = 0; i<n; i++) { S[i] = 0; for(int j=0; j<5; j++) { if(A[i][j] == K[j]) // Checking if Answer of the participants match with the
key or not
{ S[i]++; } } } } void printScore() { int max = 0; System.out.println("\nSCORES : "); for(int i = 0; i<n; i++) { System.out.println("\tParticipant "+(i+1)+" = "+S[i]);
if(S[i]>max)
{ max = S[i]; // Storing the Highest Score } } System.out.println(); System.out.println("\tHighest Score : "+max); System.out.println("\tHighest Scorers : "); for(int i = 0; i<n; i++) // Printing all those participant number who got highest score { if(S[i] == max) { System.out.println("\t\t\tParticipant "+(i+1)); } } } public static void main(String args[]) { QuizResult ob = new QuizResult(); ob.input(); ob.CalcScore(); ob.printScore(); } } Output: Enter number of participants : 4 * Enter answer of each participant row-wise in a single line * Participant 1 : A C C B D Participant 2 : B C A A C Participant 3 : B C B A A Participant 4 : C C D D B Enter Answer Key : A C D B B SCORES : Participant 1 = 3 Participant 2 = 1 Participant 3 = 1 Participant 4 = 3 Highest Score : 3 Highest Scorers : Participant 1 Participant 4

****END*************************


Question 3:


Caesar Cipher is an encryption technique which is implemented as ROT13
(‘rotate by 13 places’).
It is a simple letter substitution cipher that replaces a letter with the
letter 13 places after it in the alphabets, with the other characters
remaining unchanged.














Write a program to accept a plain text of length L, where L must be
greater than 3 and less than 100.
Encrypt the text if valid as per the Caesar Cipher. Test your program with the sample data and some random data: Example 1: INPUT : Hello! How are you? OUTPUT : The cipher text is: Uryyb? Ubj ner lbh? Example 2: INPUT : Encryption helps to secure data. OUTPUT : The cipher text is: Rapelcgvba urycf gb frpher qngn. Example 3: INPUT : You OUTPUT : INVALID LENGTH

Solution:

import java.util.*;

class Caesar

{
   public static void main(String args[])

   {

       int p=0,s=0;
       char a=0;
       Scanner sc=new Scanner(System.in);
       System.out.println("enter n");
       String n=sc.nextLine();
       n=n+" ";
       int l=n.length();
       if(l<3&&l>100)
     
{
System.out.println("invalid");
        }
        else
        {
            for(int i=0;i<l;i++)
  {
                char ch=n.charAt(i);
                if(ch>='A'&&ch<='M')
                {
                p=ch+13;
                a=(char)p;
                System.out.print(a);
            }
            else if(ch>='N'&&ch<='Z')
{
                s=ch-13;
a=(char)s;
System.out.print(a);
            }
                if(ch>='a'&&ch<='m')
{
p=ch+13;
                a=(char)p;
                System.out.print(a);
            }
            else if(ch>='n'&&ch<='z')
  {
                s=ch-13;
                a=(char)s;
                System.out.print(a);
}
  else
            {
  System.out.print(ch);
}
        }
    }
}
}


Output:

Enter a sentence : Encryption helps to secure data. OUTPUT : The cipher text is :

****END******************