Java Program to Find the Absolute Value of a Number Using Library Method

You are currently viewing Java Program to Find the Absolute Value of a Number Using Library Method

Java program to find the absolute value of a number using library method

// Java program to find the absolute value of a number 
// using the library method

import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner X = new Scanner(System.in);

    double num = 0;

    System.out.print("Enter number: ");
    num = X.nextDouble();

    System.out.print("Cube root of num is: " + Math.abs(num));
  }
}

Output

Enter number: -345
Cube root of num is: 345.0

Ranjith

Hi, I'm Manoj a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Reply