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