hi all! i'm having difficulties with arrays in java. i've got a few questions that i'm kind of stuck on and their really bugging me! i'm new to java so if anyone can help with the following questions, i'd REALY appreciate it!!!!

1) Write a loop that creates an integer array p with the values as shown:


3 6 9 12 15 18 21 24 27

2) Use another loop which makes adjustments to the values of the array p in a) as shown:


3 6 10 14 18 22 26 29 32


3) Declare a two dimensional array with 10 rows and 10 columns initialise:

a) All the elements in the 6th row to -1
b) All the elements of the 7th column to 4


4)

1 2 3 4 5
3 -22 6 8 -3
14 9 31 -1 0
52 1 13 71 29
65 15 22 33 53


Write the loops needed to print the diagonal elements of the above two dimensional array. Te elements of each diagonal are

a) 1 –22 31 71 53
b) 5 8 31 1 65


PLEASE PLEASE PLEASE can sumone help me answer these questions!! THANKS!!!!!!!!!!!!!!

If you're learning Java without a reference, get a reference. If you have a reference, READ IT! I mean, come on, how trivial does this have to be before you can figure it out on your own? Any book on Java will cover every single one of those questions. Not only that, they'll all tell you where to find the information from both the table of contents AND the index! Hell, with a beginner's book you could probably flip to somewhere in the middle and hit on at least one of the answers.

>PLEASE PLEASE PLEASE can sumone help me answer these questions!!
No. If you can't do this on your own then you're beyond any help.

I swear...

Now, now Narue. Let's be nice to our new members :) Hey there militant. We actually have a rule around these parts that we won't help with your homework unless you show us some effort that you've tried to do it yourself already. Then we'll give you a hand by pointing you in the right direction.

oh soz about that. didnt mean to offend anyone. i will take your advice. cheers for the reply anyway! :cheesy:

hi! thanks for your reply. ok wel basically, i have tried to do these questions but am getting nowhere coz i don't realy understand the java programming language too well at the moment. heres what i have attempted.

------------------------------------------------------------------------

1) Write a loop that creates an integer array p with the values as shown:

3   6   9   12  15  18  21  24  27

code

  p = new int [8]; // initialise array
  for (int i=0; i <=8; i++) // for loop
   {
     i = i + 3;
     system.out.println(p[i]);
   }

------------------------------------------------------------------------

2) Use another loop which makes adjustments to the values of the array p in a) as shown:

3   6   10  14  18  22  26  29  32

not sure about this one!

-----------------------------------------------------------------------

3) Declare a two dimensional array with 10 rows and 10 columns initialise:

a) All the elements in the 6th row to -1
b) All the elements of the 7th column to 4

p = new int [10] [10]; // intialise two dimensional array
not sure about the rest!

-----------------------------------------------------------------------

4)

1   2   3   4   5
3   -22 6   8   -3
14  9   31  -1  0
52  1   13  71  29
65  15  22  33  53

Write the loops needed to print the diagonal elements of the above two dimensional array. Te elements of each diagonal are

a) 1 –22 31 71 53
b) 5 8 31 1 65

p = new int [5] [5] // intialise two dimensional array
this is all i know! c, im stuk!!  :o 

--------------------------------------------------------------------

PLEASE PLEASE PLEASE can sumone help me answer these questions!! THANKS!!!!!!!!!!!!!!

Edited 3 Years Ago by pyTony: fixed formating

Honestly, I'm getting more and more disappointed every time I see someone say, "I'm not doing your homework for you." and I'll tell you why...

I've been a programmer for many years now. I've seen many horrible text books, on top of equally horrible professors there are out there - and I've even experienced many myself. Yes, there are going to be those students that really don't want to try, and will go to any length to cheat in order to get by. Guess what? Not surprising that they're going to fail, and there's nothing that can be done about that. They will go elsewhere to get what they're seeking. However, there are those who are honestly stuck - even if it's right out of the gate, and they don't know how to start - their books and professors aren't helping, so they turn to the Internet for guidance. This is what help forums are all about: Help. Many people need examples in order to understand how things work - or at least the pseudo code to help them through the process.

Being a very visual learner myself, learning by example is extremely helpful in turning on the ol' lightbulb - especially when most textbooks out there are so confusing for beginners. So when people ask for help with something - homework or not - and they're told "Not doing your homework!" That's not helping anyone. Don't think about those who are out there to slack off - there will always be those out there. What you need to do is help those who need to learn by example. Providing code snippets, or even the pseudo code will make a huge difference to those dedicated to learn, but shutting people down entirely is highly discouraging.

Honestly, I'm getting more and more disappointed every time I see someone say, "I'm not doing your homework for you." and I'll tell you why...

I've been a programmer for many years now. I've seen many horrible text books, on top of equally horrible professors there are out there - and I've even experienced many myself. Yes, there are going to be those students that really don't want to try, and will go to any length to cheat in order to get by.

And those that want to try will actually try first. Then, if they don't succeed on there own, they will usually use Google first. Then, even if they didn't use Google, they will come here and ask how to do something, providing info about the methods they've already tried. When tey come here and simply provide their homework assignment text (many times nearly word for word), they are simply looking to cheat.

Guess what? Not surprising that they're going to fail, and there's nothing that can be done about that. They will go elsewhere to get what they're seeking. However, there are those who are honestly stuck - even if it's right out of the gate, and they don't know how to start - their books and professors aren't helping, so they turn to the Internet for guidance. This is what help forums are all about: Help. Many people need examples in order to understand how things work - or at least the pseudo code to help them through the process.

And nearly everyone of those "examples" can be found with Google. And those "willing to try", as you say, will usually check there first, and if they don't, or if they don't find what they are looking for, then they come and ask, providing details about what they already tried, and they will get help. Usually just a nudge in the right direction, but never a complete, working, answer to their homework assignment.

Being a very visual learner myself, learning by example is extremely helpful in turning on the ol' lightbulb - especially when most textbooks out there are so confusing for beginners.

Good for you. But "students" almost always think they are under extreme stress (time limit-wise and otherwise (they don't know what real stress is yet, and theirs is normally only caused by their own lack of either planning or discipline, or their own excess of partying), so, if given a complete, working solution, 99%, even of those who want to try) will never look at it, beyond running it to make sure that it does what was requested.

So when people ask for help with something - homework or not - and they're told "Not doing your homework!" That's not helping anyone. Don't think about those who are out there to slack off - there will always be those out there. What you need to do is help those who need to learn by example. Providing code snippets, or even the pseudo code will make a huge difference to those dedicated to learn, but shutting people down entirely is highly discouraging.

And, as said above, when they have actually shown that they have taken the time to try, they will, usually, get help. So go rant somewhere else, please.

Edit:

P.S. you did realise this thread is nearly three years old, right? If not, you should maybe touch up on your "attention to detail" discipline. It could only help.

And those that want to try will actually try first. Then, if they don't succeed on there own, they will usually use Google first. Then, even if they didn't use Google, they will come here and ask how to do something, providing info about the methods they've already tried. When tey come here and simply provide their homework assignment text (many times nearly word for word), they are simply looking to cheat.

And nearly everyone of those "examples" can be found with Google. And those "willing to try", as you say, will usually check there first, and if they don't, or if they don't find what they are looking for, then they come and ask, providing details about what they already tried, and they will get help. Usually just a nudge in the right direction, but never a complete, working, answer to their homework assignment.

Good for you. But "students" almost always think they are under extreme stress (time limit-wise and otherwise (they don't know what real stress is yet, and theirs is normally only caused by their own lack of either planning or discipline, or their own excess of partying), so, if given a complete, working solution, 99%, even of those who want to try) will never look at it, beyond running it to make sure that it does what was requested.

And, as said above, when they have actually shown that they have taken the time to try, they will, usually, get help. So go rant somewhere else, please.

Edit:

P.S. you did realise this thread is nearly three years old, right? If not, you should maybe touch up on your "attention to detail" discipline. It could only help.

Wow, you know... I didn't know "pro bloggers" were the only ones allowed on this forum to have any sort of opinion on a topic. The rude thing works for you, because you surely put me in my place.

What rude thing? And because someone responded to your post your offended? What of the above points were incorrect? What of the above points do you have a response to? Oh, you were simply offended that not everyone agreed with your rant?

tech74, if you wished to leave a feedback about the way some responses are handled here you would better do it in Coffe House ==> DaniWeb Community Feedback.
There is realy no point open an old post and arguing about it. So please, if you have anything to say regarding this forum do so in section of this forum designed for this purpose

> but shutting people down entirely is highly discouraging.
Losers always crib, those interested ask sensible questions and winners pave their own way.

Honestly, I'm getting more and more disappointed every time I see someone say, "I'm not doing your homework for you." and I'll tell you why...

and I'm tired by kids who complain that they aren't getting their homework done for them without showing any effort of their own whatsoever, especially kids who claim to be in their "final year" yet don't know the first thing.
How did those kids get through the rest of their "education" if it wasn't by cheating, something you endorse and facillitate?

I've been a programmer for many years now. I've seen many horrible text books, on top of equally horrible professors there are out there - and I've even experienced many myself.

And far more good ones.
If those kids were motivated to succeed they'd go out and do their own research, not post their entire homework assignments verbatim (ever more just posting a link to a school intranet site that's not even accessible to the outside world, showing their stupidity and laziness for all the world to see) and demand that it be done "ASAP!!!!!".

Yes, there are going to be those students that really don't want to try, and will go to any length to cheat in order to get by. Guess what? Not surprising that they're going to fail, and there's nothing that can be done about that. They will go elsewhere to get what they're

And we want them to fail quickly rather than cheat their way into a diploma and ending up making the entire profession look bad in hundreds of job interviews (which will be preceded by demands to give them lists of "interview questions" with associated answers so they can cram their head full of buzzwords to awe HR flunkies.

doing your homework!" That's not helping anyone. Don't think about those who are out there to slack off - there will always be those out there. What you need to do is help those who need to learn by example. Providing code snippets, or even the pseudo code will make a huge difference to those dedicated to learn, but shutting people down entirely is highly discouraging.

If they show effort, come with specific questions, they get help.
If all they do is post their assignments and require to have it done "ugrently" they get kicked where the sun don't shine.
Pretty much like you're being kicked right now in fact...

WHooooa!!!! :-|
tech74@
don't take the offence. I believe i am also like you. more like a visual learner. I can't go through the book to learn anything. And as being slow learner, i can't follow the profs in the class. All I have to do is self-study. When I get stuck into any problem, it is very rare i can find the errors until some one else helps me out. I believe in this forum, no one with similar problem like me was discouraged. A lot of helpful people are around here. Some times I have seen some to be li'l rude, but they were discouraged later for that.
I have a friend who is really a nice person wants to help people. Sometimes I see him on campus explaining some difficult theories to some of his friends, while those guys are instead of concentrating, looks around. I can figure out no one is getting any help through out this process. One good person is getting annoyed to help, on the other hand, a reckless person is just wasting his valuable time. I believe this is the point e'one here is trying to make. Hopefully, you understand now. And hey! be regular among us to help ppl out... cheers!!!

The people looking for help are as varied as those offering.
I too am a very visual learner, and need examples, and found NO real help until this forum.
It does seem that some "helpers" only want to help those that do not need help at all.
While this post is a little silly and just looks like someone looking for answers, there is no need to berate the OP and make them feel stupid. If you do not want to help, then do not help, but if you are only here to push it in other peoples face how inept they are as compared to you, then who really needs the help?
I know I have asked ALOT of stupid questions, but I do try, and I keep trying, and sometimes I just do not get it. Ezzaral in particular turned the light on in my head more than once, and was more helpful than my first instructor. So, where some people would see my post as just lame or dumb, he took the time to walk through some very basic concepts with me and I am a better programmer today because of it.

This article has been dead for over six months. Start a new discussion instead.