arrays in java!!!

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Nov 2004
Posts: 3
Reputation: militant880 is an unknown quantity at this point 
Solved Threads: 0
militant880 militant880 is offline Offline
Newbie Poster

arrays in java!!!

 
0
  #1
Nov 14th, 2004
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!!!!!!!!!!!!!!
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,734
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 738
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

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

 
0
  #2
Nov 14th, 2004
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...
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Join Date: Feb 2002
Posts: 12,043
Reputation: cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light cscgal is a glorious beacon of light 
Solved Threads: 128
Administrator
Staff Writer
cscgal's Avatar
cscgal cscgal is offline Offline
The Queen of DaniWeb

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

 
0
  #3
Nov 14th, 2004
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.
Dani the Computer Science Gal
Follow my Twitter feed! twitter.com/DaniWeb
And if you're interested in Internet marketing there is twitter.com/DaniWebAds
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 3
Reputation: militant880 is an unknown quantity at this point 
Solved Threads: 0
militant880 militant880 is offline Offline
Newbie Poster

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

 
0
  #4
Nov 14th, 2004
oh soz about that. didnt mean to offend anyone. i will take your advice. cheers for the reply anyway! :cheesy:
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 3
Reputation: militant880 is an unknown quantity at this point 
Solved Threads: 0
militant880 militant880 is offline Offline
Newbie Poster

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

 
0
  #5
Nov 14th, 2004
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!!!!!!!!!!!!!!
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 2
Reputation: tech74 is an unknown quantity at this point 
Solved Threads: 0
tech74 tech74 is offline Offline
Newbie Poster

Re: arrays in java!!!

 
0
  #6
Sep 22nd, 2007
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.
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 2,415
Reputation: masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of 
Solved Threads: 256
Moderator
masijade's Avatar
masijade masijade is offline Offline
Nearly a Posting Maven

Re: arrays in java!!!

 
1
  #7
Sep 22nd, 2007
Originally Posted by tech74 View Post
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.
Last edited by masijade; Sep 22nd, 2007 at 4:02 am.
Java Programmer and Sun Systems Administrator

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

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 2
Reputation: tech74 is an unknown quantity at this point 
Solved Threads: 0
tech74 tech74 is offline Offline
Newbie Poster

Re: arrays in java!!!

 
0
  #8
Sep 22nd, 2007
Originally Posted by masijade View Post
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.
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 2,415
Reputation: masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of 
Solved Threads: 256
Moderator
masijade's Avatar
masijade masijade is offline Offline
Nearly a Posting Maven

Re: arrays in java!!!

 
0
  #9
Sep 22nd, 2007
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?
Java Programmer and Sun Systems Administrator

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

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 4,205
Reputation: peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of 
Solved Threads: 486
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is offline Offline
Code tags enforcer

Re: arrays in java!!!

 
0
  #10
Sep 22nd, 2007
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
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)

LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC