• Some users have recently had their accounts hijacked. It seems that the now defunct EVGA forums might have compromised your password there and seems many are using the same PW here. We would suggest you UPDATE YOUR PASSWORD and TURN ON 2FA for your account here to further secure it. None of the compromised accounts had 2FA turned on.
    Once you have enabled 2FA, your account will be updated soon to show a badge, letting other members know that you use 2FA to protect your account. This should be beneficial for everyone that uses FSFT.

need Java help... array related

pilotace001

Limp Gawd
Joined
Nov 9, 2005
Messages
232
result:
1. need to get a # (user input) of number of elements in array
2. need to give each of those elements a number (user input)
3. display the array in normal order
4. display the reverse order

I started to make it:

get user input = x and set the array[x]

then get the loop

for (i=0,i<x.length,i++) { user input
}
then what?
sustem.out.println(array) ? (has to diplay all array elenets on one disp. box)

it gives me errors when I try to convert some things to int...

workning on that now...

what would be a good way to reverse the array? (gotta be a method)

if you can help..great,
if not - it will work.....eventually
thanks
 
here's your standard for loop, right?

Code:
for (int i=0; i<10; 1++)
   some_task;

i'll give ya a hint. you can use the for statement to print the array backwards. what's the problem with the statement above that won't print it backwards?

well... it starts at 0, tests to see if i is less than 10. if it is, it does some_task if it isn't, it quits. after some_Task is executed each time, we add one to i.

....can you think of how to do what you want now?

edit.. you should have no problem convert stuff to int, because you probably SHOULDN'T be converting floats to ints or something like that..
 
Got it... friend helped me out.

{{original was i++, reverse was i-- (x.lenght-1... blah..blah)}}

That all the java I gotta worry till fall sem

now that 30% final.. :(

final result:
===3 main statements used:
for (int i = 0; i < array.length; i++) {
output += array + " ";

for (int i = 0; i < arrayReverse.length; i++) {
output += arrayReverse + " ";

for(int i = a.length - 1; i >= 0; i--) {
secondArray[count] = a;
count++;
===



thanks for the help given.
 
Back
Top