Advertisement
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 Calculator. Please Input a Number:");
- int n = keyboard.nextInt();
- do {
- if (n<0){
- System.out.println("That number is negative, please input a positive number.");
- System.out.println("Input a Number:");
- n = keyboard.nextInt();
- }
- } while (n < 0);{
- double sqrt = Math.sqrt(n);
- System.out.println("The square root of " +n+ " is " +sqrt);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement