金安民 2 months ago
parent 0c506dcbc6
commit 01a2898220

@ -1,17 +1,16 @@
package Calculator;
import java.util.Scanner; import java.util.Scanner;
public class Calculator { public class Calculator {
public static void main(String[] args) { public static void main(String[] args) {
Scanner scanner = new Scanner(System.in); Scanner scanner = new Scanner(System.in);
System.out.print("请输入要转换的数:");
String num = scanner.nextLine();
System.out.print("请输入源进制(2-16)"); System.out.print("请输入源进制(2-16)");
int fromBase = scanner.nextInt(); int fromBase = scanner.nextInt();
System.out.print("请输入目标进制(2-16)"); System.out.print("请输入目标进制(2-16)");
int toBase = scanner.nextInt(); int toBase = scanner.nextInt();
System.out.print("请输入要转换的数:");
String num = scanner.nextLine();
// 调用转换方法 // 调用转换方法
String converted = convertBase(num, fromBase, toBase); String converted = convertBase(num, fromBase, toBase);

Loading…
Cancel
Save