Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner keyboard = new Scanner (System.in);
- System.out.println("Square Root!");
- System.out.println("Enter a Number: ");
- int entry = keyboard.nextInt();
- if (entry < 0)
- do {
- System.out.println("You can't take the square root of a negative number, Silly.");
- System.out.println("Try again: ");
- entry = keyboard.nextInt();
- } while (entry < 0);
- double num = Math.sqrt(entry);
- System.out.println("The square root of " + entry + " is " + num);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment