# i beg you help me please with these two array problem using JCreator

• 01-10-2012, 08:34 AM
janroz
i beg you help me please with these two array problem using JCreator
class Exercise2
{
public static void main ( String[] args )
{
int[] val = {13, -4, 82, 17};
int[] twice;

// create a loop that can output the double value from the original array

// Construct an array object for twice.

// Put values in twice that are twice the
// corresponding values in val.

// create a loop that can output the double value from the original array

}
}
Complete the program so that a new array twice is constructed. Now copy values from val to twice, but make the values in twice double what they are in val.
• 01-10-2012, 02:20 PM
Norm
Re: i beg you help me please with these two array problem using JCreator
Do you have any specific questions or problems?
• 01-10-2012, 02:36 PM
Fubarable
Re: i beg you help me please with these two array problem using JCreator
• 01-10-2012, 03:54 PM
janroz
Re: i beg you help me please with these two array problem using JCreator
yes sir the question is in the above.

i need to create a loop that can output the double value from the original array (int[] val = {13, -4, 82, 17};)
, Construct an array object for twice and Put values in twice that are twice the corresponding values in val.
• 01-10-2012, 04:01 PM
Norm
Re: i beg you help me please with these two array problem using JCreator
Do it one step at a time.
Quote:

a loop that can output the double value
Please explain how to get a double value from an int array.
• 01-10-2012, 04:07 PM
janroz
Re: i beg you help me please with these two array problem using JCreator
i have this code but it is not working!
Code:

```import java.io.* ; class array {     public static void main ( String[] args ) throws IOException     {                 int[] val = {13, -4, 82, 17};         int[] twice;         int multiply;                             BufferedReader inData=new BufferedReader(new InputStreamReader(System.in));     // create a loop that can output the double value from the original array                      for (int i=0; i < val.length; i++)         {                System.out.print(val[i] + " \n");             multiply = val[i] * 2;     twice = new int [multiply];     System.out.print(twice + " \n");             }```
• 01-10-2012, 04:10 PM
janroz
Re: i beg you help me please with these two array problem using JCreator
the output should be
val = 13, -4, 82, 17
twice = 26, -8 , 164, 34

because the instruction said i need to give value of the "twice" comes from the x2 of the val = 13, -4, 82, 17
• 01-10-2012, 04:12 PM
Norm
Re: i beg you help me please with these two array problem using JCreator
You forgot to post what the current program prints out when it executes.

If you have errors, please copy and paste them here.
• 01-10-2012, 04:15 PM
janroz
Re: i beg you help me please with these two array problem using JCreator
ohhh! i dont have JCreator here in my desktop!
can you help me solve this problem sir? please?
• 01-10-2012, 04:16 PM
Norm
Re: i beg you help me please with these two array problem using JCreator
Please post the full text of the error messages you are getting.
• 01-10-2012, 04:19 PM
janroz
Re: i beg you help me please with these two array problem using JCreator
ok got it! the eror said "twice = new int [multiply];" Twice initialize
• 01-10-2012, 04:20 PM
Norm
Re: i beg you help me please with these two array problem using JCreator
That is NOT the full text of an error message.
It doesn't say what the error is.

Please copy full text of error message and paste it here. Here is a sample:
Code:

```TestSorts.java:138: cannot find symbol symbol  : variable var location: class TestSorts         var = 2;         ^```
• 01-10-2012, 05:40 PM
Tolls
Re: i beg you help me please with these two array problem using JCreator
Why on earth have you got a BufferedReader in there?

Honestly, don't copy code if you have no idea what it is you're looking at.
• 01-12-2012, 09:24 AM
stchman
Re: i beg you help me please with these two array problem using JCreator
Hint:

You already have the val array created, would it not be a valid assumption that the twice array would contain the same number of elements? All you would then do it to just loop through the val array, multiply by 2 and then put those values into the twice array.

You don't need BufferedReader for this since you have declared and initialized the val array.

FYI, you don't need JCreator do write Java programs. If you are using Windows, use Notepad++ as IDEs usually confuse absolute beginners.