Assignemnt #75

Code

/// Name: Connor Siri
/// Period: 7
/// Program Name: Safe
/// File Name: Safe.java
/// Date Finished: 11/1/2015

import java.util.Random;
import java.util.Scanner;

public class Safe
{
	public static void main( String[] args )
	{
		Scanner keyboard = new Scanner(System.in);
        Random r = new Random();
        
        double a, b;
        
        System.out.println("Square root");
        System.out.print("enter # ");
        a = keyboard.nextDouble();
        
        while( a < 0 )
        {
        System.out.println("You can't take the square root of a negative number");
        System.out.print("Try again: ");
        a = keyboard.nextDouble();
        }
        b = Math.sqrt(a);
        System.out.println("The square root of " + a + " is " + b );
        }
        }




    

Picture of the output

Assignment1.html