From f00ef0a623a0cfbc36cebd04b6afd15a9cf27fe3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A6=83=E4=BD=99?= <1597326398@qq.com> Date: Thu, 6 Aug 2020 21:34:05 +0800 Subject: [PATCH] b.java --- b.java | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 b.java diff --git a/b.java b/b.java new file mode 100644 index 0000000..fc43d09 --- /dev/null +++ b/b.java @@ -0,0 +1,20 @@ +//package log; +import java.util.Scanner; +public class b { + public static void main(String[] args) { + int a; + int x; + double result; + System.out.println("输入底数a(a>0且a!=1):"); + Scanner sc = new Scanner(System.in); + a=sc.nextInt(); + System.out.println("输入真数x:"); + x=sc.nextInt(); + result = log(x, a); + System.out.println(result); + } + + private static double log(double value, double base) { + return Math.log10(value) / Math.log10(base); + } +}