| | |
arrays in java!!!
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Nov 2004
Posts: 3
Reputation:
Solved Threads: 0
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!!!!!!!!!!!!!!
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...
>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.
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.
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

Follow my Twitter feed! twitter.com/DaniWeb
And if you're interested in Internet marketing there is twitter.com/DaniWebAds
•
•
Join Date: Nov 2004
Posts: 3
Reputation:
Solved Threads: 0
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!!!!!!!!!!!!!!
------------------------------------------------------------------------
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!!!!!!!!!!!!!!
•
•
Join Date: Sep 2007
Posts: 2
Reputation:
Solved Threads: 0
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.
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.
•
•
•
•
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.
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
----------------------------------------------
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
•
•
Join Date: Sep 2007
Posts: 2
Reputation:
Solved Threads: 0
•
•
•
•
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?
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
----------------------------------------------
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
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
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
Publilius Syrus
(~100 BC)
LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
![]() |
Similar Threads
- Arrays in Java (Java)
- JAVA: copying 1d array's value into a specific row of a 2d array (Java)
- strange java behaviour? (Java)
- Advantages: C++/Java (C++)
- sorting arrays in java (Java)
Other Threads in the Java Forum
- Previous Thread: need of abstract class
- Next Thread: Non-Static method cannot be referanced from a Static context
| Thread Tools | Search this Thread |
-xlint add android api applet application array arrays automation bi binary blackberry bluetooth chat class classes client code compile compiler component converter database digit eclipse equation error event exception fractal freeze functiontesting game gameprogramming givemetehcodez graphics gui health html hyper ide idea image input int integer j2me java javame javaprojects jetbrains jni jpanel jtable julia learningresources linux list login loop main map method methods mobile myregfun netbeans newbie nonstatic notdisplaying page pearl print problem program programming project qt recursion scanner screen scrollbar server set size sms sort spamblocker sql string superclass swing system thread threads time tree variablebinding windows xor






