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

Assume variables SimpleWriter out and int n are already declared in each case. W

ID: 3662874 • Letter: A

Question

Assume variables SimpleWriter out and int n are already declared in each case. Write a while loop that prints: All squares less than n. For example, if n is 100, print 0 1 4 9 16 25 36 49 64 81. All positive numbers that are divisible by 10 and less than n. For example, if n is 100, print 10 20 30 40 50 60 70 80 90. All powers of two less than n. For example, if n is 100, print 1 2 4 8 16 32 64.

Explanation / Answer

import java.util.Scanner; public class fourpointone { public static void main(String[] args) { int input, output; System.out.println("Please enter an integer"); System.out.println(); Scanner num= new Scanner(System.in); input = num.nextInt(); System.out.println(); while(input>=0){ System.out.println(Math.pow(input, 2)); --input; } System.out.println(); System.out.println("are the perfect squares less than your input"); } }