Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.text.DecimalFormat;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner in = new Scanner(System.in);
- System.out.println("Please enter in a number to find its square root value: ");
- double x = in.nextDouble(); // User inputs a number to find the square root
- // Prints the square value of the input and formats the input and output to two decimal places:
- System.out.println("Square root of " + new DecimalFormat("#.00").format(x) + " = " +
- (new DecimalFormat("#.00").format(Math.sqrt(x))));
- }
- }
Add Comment
Please, Sign In to add comment