Monday , 22 May 2017
Home » Class 12 » [Question 3] ISC 2017 Computer Practical Paper Solved – Caesar Cipher

[Question 3] ISC 2017 Computer Practical Paper Solved – Caesar Cipher

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


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



Programming Code:

 * The class CaesarCipher_ISC2017 inputs a sentence and encrypts it by shifting
 * every alphabet 13 places ahead in a circular fashion
 * @author :
 * @Program Type : BlueJ Program - Java
 * @Question Year : ISC Practical 2017 Question 3
import java.util.*;
class CaesarCipher_ISC2017
    void rot13(String w)
        char ch;
        int a = 0;
        String ans = "";
        for(int i = 0; i<w.length(); i++)
            ch = w.charAt(i);
                a = ch + 13;
                if((Character.isUpperCase(ch) && a>90) || (Character.isLowerCase(ch) && a>122))
                    a = a - 26;
                ch = (char)a;
            ans = ans + ch;
        System.out.println("OUTPUT : The cipher text is :\n"+ans);
    public static void main(String args[])
        CaesarCipher_ISC2017 ob = new CaesarCipher_ISC2017();
        Scanner sc = new Scanner(;
        System.out.print("Enter a sentence : ");
        String s = sc.nextLine();
        int L = s.length();
        if(L<4 || L>99)
            System.out.println("INVALID LENGTH");


Enter a sentence : Encryption helps to secure data.
OUTPUT : The cipher text is :
Rapelcgvba urycf gb frpher qngn.

Check Also

[Question 2] ISC 2017 Computer Practical Paper Solved – Quiz Result

Solution of Program 2 of ISC 2017 Computer Science Paper 2 (Practical) Exam. Java program to input the answers of each participant row-wise and calculate their marks


  1. Second if condition not clear…what’s the reason

    • The second if condition is to take the encoding in a cyclic manner. If the character is ‘Z’, then ‘Z’ + 13 = 90 + 13 = 103. But we want 77 which is the ASCII of ‘M’. Hence we need to subtract 26 from it. So for uppercase characters, this subtraction of 26 will take place if after adding 13, the result exceeds 90 (ASCII of ‘Z’). And for lowercase characters, this subtraction of 26 will take place if after adding 13, the result exceeds 122 (ASCII of ‘z’).

  2. Akansha chaudhary

    The string program in this year(2017) was given wrong. Those who attempted will get full marks?

  3. Hello sir,
    In my written program and algorithm, I included code to input length and my verification was also based on the length inputted. I removed this from my typed program as soon as I noticed that it wasn’t required. The program gave perfect output and I did not change anything else in my typed program. Will I lose any marks for this?
    Please reply ASAP sir as I am getting a little tensed.

  4. sir i got the output partially…the sentence was getting encrypted but it was not showing invalid length for less than 3 words.will all marks be deducted?

  5. Sir how much marks will deducted for not writing the comments in the program. If output has come and the hard copy has also been provided. But both the script as well as hard copy does not contain any commen lines.

  6. I’ve strike off four pages from my answer sheet as I’ve written wrong logic, however I continue writing the logic from four page ahead, does this affect my marks however the program is correct and it produce output?
    Thereby it’s hardcopy is also been attached with my answer but still I’m anxious about the deduction in my marks due to this work done in the answer sheet as I’ve prior explained you.

  7. Sir if my written logic is different.. Not totally right but syntactically correct.. And the typed program ‘s logic on the computer is much changed from the written one…. (Output is right).. Will i lose marks in writing and algorithm also?? If so then how much?. Plz reply asap sir…

  8. In variable list if I write an integer type variable as String in its type, by mistake, how much marks might get deducted? Also is it possible to provide a sample for question 2

  9. How long the algorithm must be

  10. Why was the exclamation mark in Example 1 changed to question mark in sample output?

  11. And what if we don’t store the characters in any variable and print them one by one , will any marks be deducted for this???

  12. Will any marks be deducted if we don’t use any function and do the whole thing in main() ???

Leave a Reply to A. Banerjee Cancel reply

Your email address will not be published. Required fields are marked *