encrypt.java
来自「简单的文字处理,可以对输入的英文语句进行大小写变化,搜索所需要的英文字母在此句中」· Java 代码 · 共 41 行
JAVA
41 行
import java.io.*;
class Encrypt {
public static void find (String lowsent, char n) {
int len=lowsent.length();
int t=0;
for (int i=0; i<len; i++) {
if (n==lowsent.charAt(i)) {
t++;
}
}
System.out.println("'"+n+"'"+" was found "+t+" times");
}
public static void main(String[] argv) {
System.out.print("Enter a sentence: ");
String sent=UserInput.readString();
System.out.println();
System.out.println("The sentence entered is: "+sent);
System.out.println("The sentence in uppercase is: "+sent.toUpperCase());
String lowsent=sent.toLowerCase();
System.out.println("The sentence in lowercase is: "+lowsent);
find(lowsent,'a');
find(lowsent,'e');
find(lowsent,'i');
find(lowsent,'o');
find(lowsent,'u');
String sent1=lowsent.replace('e','$');
String sent2=sent1.replace('s','!');
System.out.println(sent2);
} // end of main
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?