At last, my assignment 3.
/**
* Assignment 3
* @author Mr. Perferct
*/
import java.util.Scanner;
public class Assignment_3 {
private static Scanner input = new Scanner(System.in);
public static void main(String[] args) {
while (true) {
System.out.println("Your input?");
String userinput = userInput();
if (userinput.equalsIgnoreCase("quit")
|| userinput.equalsIgnoreCase("exit")) {
break;
}
System.out.println("Enter the amount you want to move the cipher?");
int move = amount();
System.out.print("The encrypted string is: ");
System.out.println(encrypt(userinput, move));
}
input.close();
}
public static String userInput() {
String userinput = input.nextLine();
return userinput;
}
private static int amount() {
String p = input.nextLine();
int places = Integer.parseInt(p);
return places;
}
private static String encrypt(String input, int places) {
char[] charArray = input.toCharArray();
for(int index = 0; index < charArray.length; index++)
{
charArray[index] += places;
}
String s = new String(charArray);
return s;
}
}