What is the output of the following Java program? import static java.lang.Math.*
ID: 3608405 • Letter: W
Question
What is the output of the following Java program? import static java.lang.Math.*; public class Exercise2 { public static voidmain(String [ ] args) { intcounter; for(counter = 1; counter <= 100; counter ++) if(pow(floor(sqrt(counter)), 2) == counter) System.out.print(counter+ " "); System.out.println( ); } } What is the output of the following Java program? import static java.lang.Math.*; public class Exercise2 { public static voidmain(String [ ] args) { intcounter; for(counter = 1; counter <= 100; counter ++) if(pow(floor(sqrt(counter)), 2) == counter) System.out.print(counter+ " "); System.out.println( ); } }Explanation / Answer
please rate - thanks the program finds and prints all perfect squares between thenumbers 1 and 100. takes a number, finds it's square root, rounds down to the wholenumber (ex if answer is 5.3 rounds down to 5) and then squares it. if back to the original number it's a perfectsquare. so 252=25 so prints 302 not=30 so doesn't print 1 4 9 16 25 36 49 64 81 100
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.