/**
* Write a description of class Caesar here.
*Shifts word
* @author Charlie Barton
* @version 1
*/
import java.util.*;
public class Caesar
{
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("");
System.out.println("Enter what you want to encrypt");
String original = scan.nextLine();
System.out.println("How much shift do you want ?");
int shif = scan.nextInt();
String alph = "abcdefghijklmnopqrstuvwxyz";
int length = original.length();
String word = "";
for (int i=0; i < length; i++){
String let = original.substring(i, i + 1);
int point = alph.indexOf(let);
int ex = (point + shif) % 26;
String r = alph.substring(ex, ex + 1);
System.out.print(r);
}
}
}
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.