This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
importjava.util.Scanner;
publicclassCalculator{
publicstaticvoidmain(String[]args){
Scannerscanner=newScanner(System.in);
System.out.print("请输入要转换的数:");
Stringnum=scanner.nextLine();
System.out.print("请输入源进制(2-16):");
intfromBase=scanner.nextInt();
System.out.print("请输入目标进制(2-16):");
inttoBase=scanner.nextInt();
// 调用转换方法
Stringconverted=convertBase(num,fromBase,toBase);
System.out.printf("%s (base %d) 转换为 base %d 是 %s%n",num,fromBase,toBase,converted);