From 1488624391a1fb59bc1f23454ed44010ef5765b0 Mon Sep 17 00:00:00 2001 From: WYB <373420785@qq.com> Date: Thu, 6 Aug 2020 19:53:58 +0800 Subject: [PATCH] log.java --- log.java | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 log.java diff --git a/log.java b/log.java new file mode 100644 index 0000000..c9c613b --- /dev/null +++ b/log.java @@ -0,0 +1,23 @@ +package calculator; +import java.util.Scanner; +public class log { + + public log() { + Scanner sc = new Scanner(System.in); + System.out.println("请输入底数a"); + double a = sc.nextDouble(); + System.out.println("请输入真数x"); + double x = sc.nextDouble(); + if(x>0&&a>0&&a!=1) + { + double result = log(a,x); + System.out.println("结果为:"+result); + } + else + System.out.println("errors "); + } + + public static double log(double a, double x){ + return Math.log(x) / Math.log(a); + } +}