JAVA的程序。急急急!

2024-11-17 11:40:59
推荐回答(1个)
回答1:

import javax.swing.JOptionPane;

public class sj {
public static void main(String[] args) {
String name = JOptionPane.showInputDialog("请输入名字");
String fname = JOptionPane.showInputDialog("请输入姓氏");
int a = (int) (Math.random() * 10 / 2);
int b = 10 + (int) (Math.random() * 100);

String name1 = name.substring(0, 1);
String fname1 = fname.substring(0, a);

JOptionPane.showMessageDialog(null, "获得的字符串为:" + name1 + fname1 + b);

}
}