Szyfr cezara - niestety się wiesza, nie działa nie mam pojęcia dlaczego - prosze o opinie co jest nie tak
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package szyfrcezara;
/**
*
* @author DK
*/
import java.util.*;
public class SzyfrCezara {
/**
* @param args the command line arguments
*/
static Scanner sc = new Scanner(System.in);
//String alphabet = "AĄBCĆDEĘFGHIJKLŁMNŃOÓPRSŚTUWYZŹŻ";
static int klucz;
public static String InputFromUser(){
System.out.println("Enter your text to encrypt");
String text = sc.nextLine();
return sc.nextLine();
}
public static int getUserInput(){
System.out.println("Enter distance between [- 26: 26]");
klucz = sc.nextInt();
return sc.nextInt();
}
public static String encrypt(String text){
for(int i = 0; i < text.length(); i++){
int c = (int)text.charAt(i);
if(c + klucz > 26){
c = 65 + (klucz - 62) % 26;
}
else{
c += klucz;
}
}
return text;
}
public static void main(String[] args) {
// TODO code application logic her
SzyfrCezara sz = new SzyfrCezara();
String text = SzyfrCezara.InputFromUser();
System.out.println(text);
klucz = SzyfrCezara.getUserInput();
System.out.println(klucz);
String c = SzyfrCezara.encrypt(text);
System.out.println(c);
}
}