Guest User

Untitled

a guest
Oct 23rd, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. import java.text.DecimalFormat;
  2. import java.util.Scanner;
  3. public class Main {
  4.  
  5. public static void main(String[] args) {
  6. Scanner in = new Scanner(System.in);
  7. System.out.println("Please enter in a number to find its square root value: ");
  8. double x = in.nextDouble(); // User inputs a number to find the square root
  9.  
  10. // Prints the square value of the input and formats the input and output to two decimal places:
  11. System.out.println("Square root of " + new DecimalFormat("#.00").format(x) + " = " +
  12. (new DecimalFormat("#.00").format(Math.sqrt(x))));
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21. }
  22. }
Add Comment
Please, Sign In to add comment