An easy Caesar Cipher ISC Practical 2017 Program 3
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: Uryyb? Ubj ner lbh? Example
Caesar Cipher is an encryption technique that is implemented as ROT13. 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.
Watch Java videos

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:
Uryyb? Ubj ner lbh?
Example 2
INPUT : Encryption helps to secure data.
OUTPUT : Rapelcgvba urycf gb frpher qngn.
Example 3
INPUT : You
OUTPUT : INVALID LENGTH
import java.io.*;
public class caeser_cipher
{
String str,str2="";
int len;
void input()throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("enter the string");
str=br.readLine();
len=str.length();
}
void compute()
{
char ch,ch2;
int l,m;
for(int i=0;i<len;i++)
{
ch=str.charAt(i);
if(Character.isLetter(ch)==true)
{l=(int)ch;
if(l==97||l<=109||l==65||(l<=77&&l<90))
{
m=l+13;
ch2=(char)m;
str2+=ch2;
}
else
{
m=l-13;
ch2=(char)m;
str2+=ch2;
}
}
else
str2+=ch;
}
}
void display()
{
System.out.println("the original string was:"+str);
System.out.println("the cipher string is:"+str2);
}
public static void main()throws IOException
{
caeser_cipher obj=new caeser_cipher();
obj.input();
obj.compute();
obj.display();
}
}Pronic Number
Related Posts
Continue learning with these related articles

Logic Gates for ISC Class 11: Truth Tables, Universal Gates, Half and Full Adder
ISC Class 11 Computer Science notes on logic gates: AND, OR, NOT, NAND, NOR, XOR and XNOR with truth tables, why NAND and NOR are universal gates, and half adder and full adder circuits with their Boolean expressions.
Decimal to Binary Conversion in Java: 3 Programs with Examples
How to convert a decimal number to binary on paper and in Java: three programs (String, place value and Integer.toBinaryString), binary to decimal, a dry run and common mistakes.

ISC Class 11 Computer Science Sample Paper 2026-27 with Solutions
A full 70-mark ISC Class 11 Computer Science sample paper for the 2026-27 annual exam: MCQs, number systems, propositional logic, logic gates, Java classes, arrays, strings, searching and sorting, and computing ethics, with complete worked solutions.