Assignemnt #74 and Safe Square Root Code /// Name: Yordan Rashkov /// Period: 7 /// Program Name: safe square root /// File Name: safesquareroot.java /// Date Finished: 1/26/2016 import java.util.Scanner; public class safesquareroot { public static void main( String[] args ) { Scanner keyboard = new Scanner(System.in); boolean isPositiveNumber = true; double g1, squareRoot; int number; squareRoot = number / 2; System.out.println(" SQUARE ROOT! "); System.out.println(); System.out.println("Enter a number: "); number = keyboard.nextInt(); System.out.println(); if ( number == 0 ) { System.out.println("Square root of "+number+" = "+0); } else if ( number<0 ) { System.out.println(" You cannot take the square root of a negative number! "); System.out.println(); System.out.println(); System.out.println(" Choose another number please: "); number = keyboard.nextInt(); } System.out.println(); System.out.println(); System.out.println(); while((g1-squareRoot)!=0); { g1=squareRoot; squareRoot = (g1 + (number/g1))/2; } if(isPositiveNumber) { System.out.println("Square roots of "+number+" are "); System.out.println("+"+squareRoot); System.out.println("-"+squareRoot); } else { System.out.println("Square roots of -"+number+" are "); System.out.println("+"+squareRoot+" i"); System.out.println("-"+squareRoot+" i"); } } }