+ 1

what am i missing??

sooo heres the code... import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int length = scanner.nextInt(); int[] sides = new int[length]; for (int i = 0; i < length; i++) { sides[i] = scanner.nextInt(); //your code goes here system.out.println(sides[i]*sides[i]); } } } i dont understand what i did wrong, i get this message when i run /usercode/Main.java:13: error: package system does not exist system.out.println(sides[i]*sides[i]); ^ 1 error heres the problem:Your company is writing a program for a geometry course. The program takes the number of squares as the first input, creates an array, and then takes the sides of squares as its elements. Write the part of the program that receives a list of square sides and prints the area of those squares for the user. Sample Input 2 3 4 Output 9 16 Explanation In this example we have 2 squares (the first input) and their sides accordingly - 3 and 4 (the second and the third inputs). The area of the first square is 9 (3*3), the second one 16 (4*4).

10th Jun 2022, 1:52 PM
bearock games
3 Answers
+ 4
About Current error: //system.out.println(. . .) ; 1st s should be capital System.out.println(...); You will get other errors also because i is undefined in print. You need again loop... as you taking input by loop, same way you need to calculate area.. hope it helps......
10th Jun 2022, 2:31 PM
Jayakrishna šŸ‡®šŸ‡³
+ 3
bearock games System is a class and Class Name starts from Capital letter. 1 - If you want to multiply in same loop then don't use another array. Scanner scanner = new Scanner(System.in); int length = scanner.nextInt(); for (int i = 0; i < length; i++) { int a = scanner.nextInt(); //your code goes here system.out.println(a * a); } 2 - If you want to take another array then use another loop Scanner scanner = new Scanner(System.in); int length = scanner.nextInt(); int[] sides = new int[length]; for (int i = 0; i < length; i++) { sides[i] = scanner.nextInt(); } //your code goes here for (int j = 0; j < length; j++) { System.out.println(sides[j]*sides[j]); }
10th Jun 2022, 2:59 PM
AĶ¢J
AĶ¢J - avatar
0
Ohhh i see AĶ¢J thank you, insolve it earlier though, it was a syntax mistake. But i ear what you are saying.
10th Jun 2022, 10:08 PM
bearock games