Last active
December 26, 2015 11:39
-
-
Save joeyv/7145566 to your computer and use it in GitHub Desktop.
Displays the square roots of 25 and every number 5 less than it until you reach 0.
Using a while loop and for loop
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) | |
{ | |
int base = 25; | |
while(base > 0){ | |
System.out.println("Square root of " + base + "\t= " + Math.sqrt(base)); | |
base -= 5; | |
} | |
} | |
} |
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) | |
{ | |
int base = 25; | |
for (base = 25; base > 0; base -= 5){ | |
System.out.println("Square root of " + base + "\t= " + Math.sqrt(base)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment