Program to print absolute value of a number entered by the user JAVA


Write a Program to print absolute value of a number entered by the user.




import java.util.*;
class absolute
{
    public static void main(String args[])
    {
         Scanner sc = new Scanner(System.in);
         int n = sc.nextInt();
         if(n < 0)
     
         System.out.println((-1)*n);
         
         else
     
         System.out.println(n);
         
    }
}



     
                     

Contact Us

REACH US

SERVICES

  • CODING
  • ON-LINE PREPARATION
  • JAVA & PYTHON

ADDRESS

B-54, Krishna Bhawan, Parag Narain Road, Near Butler Palace Colony Lucknow
Contact:+ 919839520987
Email:info@alexsir.com