|
|
|
@ -2,7 +2,7 @@ import javax.swing.JOptionPane;
|
|
|
|
|
|
|
|
|
|
public class jinzhi {
|
|
|
|
|
|
|
|
|
|
// 将数字从 'fromBase' 转换为 'toBase'111
|
|
|
|
|
// 将数字从 'fromBase' 转换为 'toBase'
|
|
|
|
|
public static String convertBase(String number, int fromBase, int toBase) {
|
|
|
|
|
// 第一步:从 'fromBase' 转换为十进制(base 10)
|
|
|
|
|
int decimalNumber = 0;
|
|
|
|
@ -58,9 +58,9 @@ public class jinzhi {
|
|
|
|
|
|
|
|
|
|
// 转换数字并打印结果
|
|
|
|
|
String result = convertBase(number, fromBase, toBase);
|
|
|
|
|
String message111 = "进制为 " + fromBase + " 的数: " + number + " 在进制为 " + toBase + " 的数是: " + result;
|
|
|
|
|
String message = "进制为 " + fromBase + " 的数: " + number + " 在进制为 " + toBase + " 的数是: " + result;
|
|
|
|
|
|
|
|
|
|
// 使用弹窗显示结果
|
|
|
|
|
JOptionPane.showMessageDialog(null, message111);
|
|
|
|
|
JOptionPane.showMessageDialog(null, message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|