/**
* Write a description of class CaesarShift here.
*
* @author (your name)
* @version (a version number or a date)
*/
import java.util.*;
public class CaesarShift
{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int shift = 4;
String en = "";
String a = "abcdefghijklmnopqrstuvwxyz";
System.out.println("Enter a word to be encrypted");
String in = sc.next();
int ln = in.length();
int count = 0;
while(count<ln){
String temp = in.substring(count, count+1);
int spot = a.indexOf(temp);
int shiftedspot = (spot +shift)%26;
en += a.substring(spot+shift, spot+shift+1);
count++;
}
System.out.println(en);
}
}
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.