Assignemnt #74

Code

          /// Holden Ganch
          /// Period 7
          /// Program name sevety fourth program
          /// File name Squareroot.java
          /// Date Finished 2/1/16
          
          import java.util.Random;
          import java.util.Scanner;
          
          public class SquareRoot
          {
          	public static void main( String[] args )
          	{
          		Scanner keyboard = new Scanner(System.in);
                  Random r = new Random();
                  
                  double a, b;
                  
                  System.out.println(" Enter a number and ill take the Square root of it");
                  System.out.println(" Your #:   ");
                  a = keyboard.nextDouble();
                  
                  while( a < 0 )
                  {
                  System.out.println("I cannot do the square root of a negative number");
                  System.out.println("If you do want negative number than just take positive number with 'i' at end");
                  System.out.println("Example root -9 is 3i");
                  System.out.print("Anyways Try again with a positive number: ");
                  a = keyboard.nextDouble();
                  }
                  b = Math.sqrt(a);
                  System.out.println("The square root of " + a + " is " + b );
                  }
                  }

    
   




    

Picture of the output

Assignment 74