Program to demonstrate how to calculate Exponential of a number in Java.
Click here to download complete source code
Output of the program :
Click here to download complete source code
package com.hubberspot.code;
import java.util.Scanner;
public class ExponentialCalculation {
public static void main(String[] args) {
// Create a Scanner object which will read
// values from the console which user enters
Scanner scanner = new Scanner(System.in);
// Getting input from user from the console
System.out.println("Enter value of number ");
// Calling nextDouble method of scanner for
// taking a double value from user and storing
// it in number variable
double number = scanner.nextDouble();
System.out.println();
System.out.println("Calculating exponential of a number ... ");
// In order to calculate exponential of a number
// we use Math class exp() static method which takes in a
// number and returns back the exponential of a number
double result = Math.exp(number);
// printing the result on the console
System.out.println("Exponential of " + number + " is : " + result);
}
}
Click here to download complete source code Output of the program :
