Tuesday, September 8, 2020

JAVA Program | Square root of input number using Sqrt Method | Diploma Computer Engineering

 

//JAVA Program to find Square Root of Input Number

package Diploma;

import java.util.Scanner;

/**

 *

 * @author Ashok Roshan

 */

public class Squareroot1 

{

   public static void main(String args[]) {

       Scanner scanner = new Scanner(System.in);

        System.out.println("Enter number to find square root in Java : ");

        double square = scanner.nextDouble();

        double squareRoot = Math.sqrt(square);

        System.out.printf("Square root of number: "+square+" is "+ squareRoot);

   

    }

}


/*

Output

Enter number to find square root in Java : 

9

Square root of number: 9.0 is 3.0BUILD SUCCESSFUL (total time: 3 seconds)

*/

No comments:

Post a Comment

CMS - 2024 || JAC INTERMEDIATE EXAMINATION - 2024 || 12th COMPUTER SCIENCE!

  Part-A Multiple Choice Questions 1) Who is the developer C++? a) Von Neumann b) Dennis M. Ritchie c) Charles Babbage d) Bjarne Stroustrup ...