Java code is right here to show.
- import java.util.Scanner;
- import java.io.*;
- public class Demo {
- public static void main(String[] args) throws Exception {
- BufferedReader br = new BufferedReader(new InputStreamReader(System. in ));
- System.out.println("1-Want logarithm value of a number..?");
- System.out.println("2-Want power of a number..?");
- System.out.println();
- System.out.print("Select any option: ");
- int select = Integer.parseInt(br.readLine());
- switch (select) {
- case 1:
- System.out.print("Enter the number: ");
- Scanner in = new Scanner(System. in );
- float input = in .nextFloat();
- System.out.println("Natural logarithm value of " + input + " is : " + Math.log(input));
- break;
- case 2:
- System.out.print("Enter the number: ");
- Scanner s = new Scanner(System. in );
- int input1 = s.nextInt();
- System.out.print("Enter the power value: ");
- int input2 = s.nextInt();
- System.out.println("The value of " + input1 + " raised to the power " + input2 + " is: " + Math.pow(input1, input2));
- break;
- }
- }
- }
Thank you, keep learning and sharing.