I am on an Java encryption program where it prompts user to map his/her own String sequence from A-Z, 0-9, full stop, comma, exclamation mark and Space.
The programs runs like this:
User enter a String of different sequence from this:
String original= "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.,!";
String example= "!,.1234567890QWERTYUIOPASDFGHJKLZXCVBNM"
User will now choose to encrypt his own String.
Example output:
Text to Encrypt: ENCRYPT
Encrypted Text: 2Q.TSEU
User can also choose to decrypt a String.
Text to Decrypt: 2Q.TSEU
Decrypted Text: ENCRYPT
However, I am unable to take in Space
input for user's preferred String to encrypt.
I tried using .nextLine()
instead of .next()
but I met some bugs.
When I use String textToEncrypt= sc.nextLine();
this is the output I get.
Text to Encrypt: Encrypted Text:
--------------------------------------------------------------------
(1-Encrypt) (2-Decrypt) (3-Quit):
Instead of allowing user to enter the text, it jumps to the next line immediately and goes back to the while
loop which asks for user's choice.