# I need help on solving an exercise from school

• 12-30-2010, 09:27 PM
dekelm12
I need help on solving an exercise from school
Hi,
I began my journey in Java a few months ago so I'm a beginner.
I learn it in my school.
Anyway I got an assignment that I need help with.
How do I do the following assignment?

Write a code that inputs 10 numbers into a one-dimensional array - a.
The code will define a new array - b which is made of the array a in the power of 2.
The code will define an array - c, which is made of the product of the number in array - a with the numbers in array - b in a correspondence way.
The code will output in the first row the numbers of array - a.
In the second row, the numbers of array - b will be outputted.
In the third row, the numbers of array - c will be outputted.

That's it Thanks!

Code:

```import java.util.Scanner; public class daf167 {   public static void main(String[]args)   {     Scanner in= new Scanner(System.in);     int[] a= int[10];     int[] b= int[10];     int[] c= int[10];     int i;     for(i=0;i<=9;i++)     {       System.out.println("Enter a number");     a[i]=in.nextInt();     for(i=0;i<=9;i++)       b[i]=a[i]*a[i];     for(i=0;i<=9;i++)       c[i]=a[i]*b[i]     }     System.out.println("The first row - a is" +a[i]);     System.out.println("The second row - b is" +b[i]);     System.out.println("The third row - c is" +c[i]);   } }```
This is what I've done. What's wrong with it? It doesn't work.

By the way, do you have any tips for Java beginners?
• 12-31-2010, 01:35 AM
Hibernate
“Alignment”, do you mean array?
Don't you have any book to read, this is rather basic stuff?
We can't just do your assignment for you, post the solution though should have worked, and maybe we can help you.
• 12-31-2010, 11:01 AM
dekelm12
Quote:

Originally Posted by Hibernate
“Alignment”, do you mean array?
Don't you have any book to read, this is rather basic stuff?
We can't just do your assignment for you, post the solution though should have worked, and maybe we can help you.

Well English isn't my mother language, so I guess it's array.
Anyways, I need the solution. Will someone help me with that?
• 12-31-2010, 12:01 PM
Prajin
Quote:

Well English isn't my mother language, so I guess it's array.
Anyways, I need the solution. Will someone help me with that?
Many of us mother language also isn't English. That's not problem.
The real problem is, you asking us to do your assignment. Don't you think, you should at least try and show your effort. We are here to help, not solve your entire problem by writing codes.

For beginners, there are always lot of books to read.

-Regards
• 12-31-2010, 12:24 PM
dekelm12
Quote:

Originally Posted by Prajin
Many of us mother language also isn't English. That's not problem.
The real problem is, you asking us to do your assignment. Don't you think, you should at least try and show your effort. We are here to help, not solve your entire problem by writing codes.

For beginners, there are always lot of books to read.

-Regards

How about trying to help me instead of lecturing me in what is wrong and what is right?
• 12-31-2010, 12:59 PM
dekelm12
Code:

```import java.util.Scanner; public class daf167 {   public static void main(String[]args)   {     Scanner in= new Scanner(System.in);     int[] a= int[10];     int[] b= int[10];     int[] c= int[10];     int i;     for(i=0;i<=9;i++)     {       System.out.println("Enter a number");     a[i]=in.nextInt();     for(i=0;i<=9;i++)       b[i]=a[i]*a[i];     for(i=0;i<=9;i++)       c[i]=a[i]*b[i]     }     System.out.println("The first row - a is" +a[i]);     System.out.println("The second row - b is" +b[i]);     System.out.println("The third row - c is" +c[i]);   } }```
This is what I've done. What's wrong with it? It doesn't work.
• 12-31-2010, 01:23 PM
dekelm12
Never mind guys, I managed to solve it by myself :)