From 01a2898220fbc42bc23c8743e03163ff68ecf81d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=87=91=E5=AE=89=E6=B0=91?= <3233449392@qq.com> Date: Thu, 10 Oct 2024 17:01:30 +0800 Subject: [PATCH] 2 --- Calculator.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Calculator.java b/Calculator.java index 5405f22..751b8e4 100644 --- a/Calculator.java +++ b/Calculator.java @@ -1,17 +1,16 @@ +package Calculator; import java.util.Scanner; public class Calculator { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); - - System.out.print("请输入要转换的数:"); - String num = scanner.nextLine(); - System.out.print("请输入源进制(2-16):"); int fromBase = scanner.nextInt(); - System.out.print("请输入目标进制(2-16):"); int toBase = scanner.nextInt(); + System.out.print("请输入要转换的数:"); + String num = scanner.nextLine(); + // 调用转换方法 String converted = convertBase(num, fromBase, toBase); @@ -41,4 +40,4 @@ public class Calculator { return result.toString(); } -} +} \ No newline at end of file