Monday , 15 October 2018
Latest Posts
Home » Class 12 » [Question 3] ISC 2017 Computer Practical Paper Solved – Caesar Cipher

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

#### Question:

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

#### Programming Code:

```/**
* The class CaesarCipher_ISC2017 inputs a sentence and encrypts it by shifting
* every alphabet 13 places ahead in a circular fashion
* @author : www.guideforschool.com
* @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);
if(Character.isLetter(ch))
{
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.in);
System.out.print("Enter a sentence : ");
String s = sc.nextLine();
int L = s.length();
if(L<4 || L>99)
{
System.out.println("INVALID LENGTH");
}
else
{
ob.rot13(s);
}
}
}```

#### Output:

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

## ISC 2017 Computer Science Solution + Examiner’s Comments – From the Council

Solution of ISC 2017 Computer science Paper as provided by the Council for the Indian School Certificate Examinations.

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?

• The sample input / output had typing mistake. The question did not.

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?

• No marks will be deducted

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?

• 1-2 marks only 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.

• No marks will be deducted for striking off pages and writing after that.

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…

• You may lose a maximum of 3-5 marks or less.

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

• No marks will be deducted

9. How long the algorithm must be

• No specific length

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

• That was a typing mistake

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???

• No, because the question did not specify to create a new String.

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