Last active
December 26, 2015 09:18
-
-
Save imryan/7127933 to your computer and use it in GitHub Desktop.
Calculates square root of 25 and 5 less until 0 is reached.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Root { | |
public static void main(String[] args) | |
{ | |
// Declare base as an integer with a value of 30 | |
int base = 30; | |
while (base != 0) { | |
// Decrease base by -5 | |
base -= 5; | |
// Output square root of each new base | |
System.out.println("Square root of: " + base + "\t=\t" + Math.sqrt(base)); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Root2 { | |
public static void main(String[] args) | |
{ | |
// Declare base as an integer with a value of 25 | |
int base = 25; | |
// Loop base as -5 each time | |
for (base = 25; base > 0; base -= 5) | |
{ | |
// Output square root of each new base | |
System.out.println("Square root of: " + base + "\t=\t" + Math.sqrt(base)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment