![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/2ecdc2e4f0e4c1d49980e6e5188a1ac5.png#pic_center)
package test;
import java.util.Scanner;
public class Test14 {
public static void main(String[] args) {
method1();
method2();
}
private static void method1() {
System.out.println("INPUT STRING : ");
Scanner scanner = new Scanner(System.in);
String str = scanner.next();
String newStr = str.replace("A", "4")
.replace("E", "3")
.replace("G", "6")
.replace("I", "1")
.replace("O", "0")
.replace("S", "5")
.replace("Z", "2");
System.out.println(newStr);
}
private static void method2() {
System.out.println("INPUT STRING : ");
Scanner scanner = new Scanner(System.in);
String str = scanner.next();
StringBuffer sb = new StringBuffer();
for (int i = 0; i < str.length(); i++) {
char c = str.charAt(i);
switch (c) {
case 'A':
sb.append("4");
break;
case 'E':
sb.append("3");
break;
case 'G':
sb.append("6");
break;
case 'I':
sb.append("1");
break;
case 'O':
sb.append("0");
break;
case 'S':
sb.append("5");
break;
case 'Z':
sb.append("2");
break;
default:
sb.append(c);
break;
}
}
System.out.println(sb.toString());
}
}