Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

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

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote