Answer to Question #290935 in Java | JSP | JSF for rainbow

Question #290935

 Square to the Next Level

by CodeChum Admin

We've already tried printing out the values of an array in reversed order, right? Today, we shall compute for the squares of all the numbers.


There's already a predefined array/list containing 100 integer values. Loop through each values, compute their squares, and display them.


1
Expert's answer
2022-01-26T12:55:09-0500
public class App {

	public static void main(String[] args) {
		int numbers[] = new int[100];

		for (int i = 0; i < 100; i++) {
			numbers[i] = (int) (Math.random() * 100);
		}
		for (int i = 0; i < 100; i++) {
			System.out.println((numbers[i] * numbers[i]));
		}
	}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS