import java.io.*;
import hsa.Console;
import java.awt.*;
public static void main(String[] args) throws IOException {
c = new Console();
String sentence;
String encrypt = "";
String vowels = "AEIOUaeiou";
final String PUNCTAUTION = ".,;?!\"\\/\' -";
StringBuffer removePunctation = new StringBuffer();
StringBuffer thirdLetters = new StringBuffer();
char tempChar;
//Open The Output File
PrintWriter output;
output = new PrintWriter(new FileWriter("output.txt"));
c.println("Please enter the sentence you would like to encrypt");
sentence = c.readLine();
for (int i = 0; i < sentence.length(); i++) {
tempChar = sentence.charAt(i);
if (PUNCTAUTION.indexOf(tempChar) == -1) {
encrypt = encrypt + tempChar;
}
}
if (encrypt == 'A') {
sentence.replace('A', '!');
} else if (encrypt == 'I') {
sentence.replace('I', '#');
} else if (encrypt == 'E') {
sentence.replace('E', '@');
} else if (encrypt == 'O') {
sentence.replace('O', '$');
} else if (encrypt == 'U') {
sentence.replace('U', '%');
}
c.println(encrypt.toString().toUpperCase());
output.println(encrypt.toString().toUpperCase());
}
我正在尝试删除所有标点符号和空格,并将元音 AEIOU 更改为 !@#$%,但出现错误。我也试图输出我从底部句子中替换的元音并将它们反转。