So I have gotten most of my code written and I have the logic down however i cannot seem to get the program to run...
When I run it, it just runs the program I ran before this one. I will post my code: I believe it has something to do with my class declarations.
Thanks- as always for your help.
When I run it, it just runs the program I ran before this one. I will post my code: I believe it has something to do with my class declarations.
import java.util.Scanner;
public class Cipher {
public void run(){
Scanner sc = new Scanner(System.in);
int shift = sc.nextInt();
String plaintext = sc.nextLine();
String ciphertext = encryptline(plaintext , shift);
System.out.println(ciphertext);
}
private String encryptline(String str, int shift){
String cipher = "";
for (int i=0 ; i< str.length() ; i++){
char letter = encryptletter(str.charAt(i) , shift);
cipher += letter;
}
return cipher;
}
private char encryptletter(char letter, int shift){
if (Character.isLetter(letter)){
letter = (char) ('A' + (Character.toUpperCase(letter) - 'A' + shift) % 26);
}
return letter;
}
}
Thanks- as always for your help.