# Thread: I need help on solving an exercise from school

1. Member
Join Date
Dec 2010
Posts
8
Rep Power
0

## 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!

Java 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?
Last edited by dekelm12; 12-31-2010 at 12:03 PM.

2. “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.

3. Member
Join Date
Dec 2010
Posts
8
Rep Power
0
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?

4. 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.

Suggestion : Why not Google your question?
For beginners, there are always lot of books to read.

-Regards

5. Member
Join Date
Dec 2010
Posts
8
Rep Power
0
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.

Suggestion : Why not Google your question?
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?

6. Member
Join Date
Dec 2010
Posts
8
Rep Power
0
Java 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.

7. Member
Join Date
Dec 2010
Posts
8
Rep Power
0
Never mind guys, I managed to solve it by myself :)

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•