/**
* Write a description of class ceasershift here.
*
* @author (your name)
* @version (a version number or a date)
*/
import java.util.*;
public class ceasershift
{
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.