import java.util.Scanner; public class Encryption { public Encryption () { //Empty constructor. } public void run() { boolean quit = false; Scanner input = new Scanner(System.in); while(quit == false) { System.out.println("Please enter a number between 1 and 26 or q to quit.\n"); // Accept the user input String userKey = input.next(); // Check to see if the user is quitting instead of entering in a new number if( userKey.charAt(0) == 'q' ) { quit = true; // Exits out of the loop System.out.println("Now exiting..."); } else { // Convert user input into a number int userNum = Integer.parseInt(userKey); // Check if the number is within the valid range if( userNum > 0 || userNum < 27 ) { System.out.println("Enter the message you wish to encrypt:\n"); String userMessage = input.next(); for(int i = 0; i < userMessage.length(); i++) { userMessage.charAt(i); } } else { System.out.println("Error: Please enter a number between 1 and 26 or q to quit."); } } } // Close the input stream input.close(); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)