944,150 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 5028
  • Java RSS
You are currently viewing page 1 of this multi-page discussion thread
Nov 14th, 2004
0

arrays in java!!!

Expand Post »
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!!!!!!!!!!!!!!
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
militant880 is offline Offline
3 posts
since Nov 2004
Nov 14th, 2004
0

Re: arrays in java!!! PLEASE HELP!!!!!!!!!!!

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...
Administrator
Reputation Points: 6442
Solved Threads: 1393
Bad Cop
Narue is offline Offline
11,807 posts
since Sep 2004
Nov 14th, 2004
0

Re: arrays in java!!! PLEASE HELP!!!!!!!!!!!

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.
Administrator
Staff Writer
Reputation Points: 1422
Solved Threads: 163
The Queen of DaniWeb
cscgal is offline Offline
13,646 posts
since Feb 2002
Nov 14th, 2004
0

Re: arrays in java!!! PLEASE HELP!!!!!!!!!!!

oh soz about that. didnt mean to offend anyone. i will take your advice. cheers for the reply anyway! :cheesy:
Reputation Points: 10
Solved Threads: 0
Newbie Poster
militant880 is offline Offline
3 posts
since Nov 2004
Nov 14th, 2004
0

Re: arrays in java!!! PLEASE HELP!!!!!!!!!!!

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

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!!!!!!!!!!!!!!
Reputation Points: 10
Solved Threads: 0
Newbie Poster
militant880 is offline Offline
3 posts
since Nov 2004
Sep 22nd, 2007
0

Re: arrays in java!!!

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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
tech74 is offline Offline
2 posts
since Sep 2007
Sep 22nd, 2007
1

Re: arrays in java!!!

Click to Expand / Collapse  Quote originally posted by tech74 ...
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.

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

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

Quote ...
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.
Last edited by masijade; Sep 22nd, 2007 at 4:02 am.
Moderator
Reputation Points: 1471
Solved Threads: 490
Industrious Poster
masijade is offline Offline
4,043 posts
since Feb 2006
Sep 22nd, 2007
0

Re: arrays in java!!!

Click to Expand / Collapse  Quote originally posted by masijade ...
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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
tech74 is offline Offline
2 posts
since Sep 2007
Sep 22nd, 2007
0

Re: arrays in java!!!

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?
Moderator
Reputation Points: 1471
Solved Threads: 490
Industrious Poster
masijade is offline Offline
4,043 posts
since Feb 2006
Sep 22nd, 2007
0

Re: arrays in java!!!

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
Moderator
Featured Poster
Reputation Points: 2786
Solved Threads: 874
Code tags enforcer
peter_budo is offline Offline
6,659 posts
since Dec 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: Calculating Disocunt rate
Next Thread in Java Forum Timeline: Non-Static method cannot be referanced from a Static context





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC