Advertisement
IanO-B

Untitled

Dec 10th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class Main {
  3.  
  4. public static void main(String[] args) {
  5. Scanner keyboard = new Scanner(System.in);
  6. System.out.println("Square Root Calculator. Please Input a Number:");
  7. int n = keyboard.nextInt();
  8. do {
  9. if (n<0){
  10. System.out.println("That number is negative, please input a positive number.");
  11. System.out.println("Input a Number:");
  12. n = keyboard.nextInt();
  13. }
  14. } while (n < 0);{
  15. double sqrt = Math.sqrt(n);
  16. System.out.println("The square root of " +n+ " is " +sqrt);
  17. }
  18. }
  19.  
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement