Blonk

Untitled

Dec 9th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.65 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.  
  5.     public static void main(String[] args) {
  6.  
  7.         Scanner keyboard = new Scanner (System.in);
  8.  
  9.         System.out.println("Square Root!");
  10.         System.out.println("Enter a Number: ");
  11.         int entry = keyboard.nextInt();
  12.  
  13.         if (entry < 0)
  14.         do {
  15.             System.out.println("You can't take the square root of a negative number, Silly.");
  16.             System.out.println("Try again: ");
  17.             entry = keyboard.nextInt();
  18.  
  19.         } while (entry < 0);
  20.         double num = Math.sqrt(entry);
  21.         System.out.println("The square root of " + entry + " is " + num);
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment