Tariq Ab

Greenhorn
+ Follow
since Oct 24, 2009
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
2
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Tariq Ab

Got It!

with your explaination and this sample code, I was able to fully understand this concept

http://mathbits.com/mathbits/java/looping/nestedfor.htm

Thanks again
12 years ago
Thank you for your reply!

I accidently mixed up the left and right sides

I understand it a little better now. I got why Y keeps repeating 3-4-3-4.
But I'm still not sure about X. I know I'm missing something, Its probably stupid but why does it repeat twice before each increment

12 years ago
Here is the output:

0 4
0 3
1 4
1 3
3 4
3 3

Why do the right side (X) repeat itself twice? Shouldn't the second value of x be 3?
This is how i came to this conclusion: When X leaves the for loop for the first time, it gets incremented to 1. Then it enters the If statement, which increments the X value to X ( ok now im confused
As for the left side (Y) I understand as far as the second output, but why does it output 4 again?

Thank you

12 years ago
Thank you so much Sir,

Finally got it. had to read it a couple of times letter by letter.

Now i can go to bed
12 years ago
I don't understand how we got the output?!!
What's the first output in line 14? how do we calculate what's the value coming out of the loop? line 12?!





Answer is 13 15 x = 6
12 years ago
My question is, why did we initializae the value of z to -1?
Couldn't we just set it to 0 and get it to loop 0 through 2?

Another question, is using the 2 IF statements effecient here? couldn't we just stayed with the while loop statement for the rest array values?

hope my questions make sense and appreciate your help

12 years ago
Hi,

I'm preparing for my SCJA exam and I'm not sure what book should i get. I've read some good reviews on the Cameron McKenzie's book, but it seems there are 2.

Amazon
http://www.amazon.com/SCJA-Certification-Technology-ExamScam-com-Programmers/dp/1598726102

and

Barnes & Noble
http://www.barnesandnoble.com/w/cameron-mckenzies-scja-sun-certified-java-associate-cameron-w-mckenzie/1013458811#Details

Is there any difference between the 2?
If not, I prefer to get the one from Barnes and Noble

Thanks,


12 years ago
sorry about that.

this is what i get:

main method not found in class DrumKit, please define the main method as: public static void main (String[] args )
12 years ago
Hi,

I'm having a problem running this program. It compiles and everything but for some reason it doesn't run
I'm still a noob so i know it must be something silly

12 years ago
Great!

I'm glad its just not my fault.

Thank you
12 years ago
Hi,

I just have a quick question.
I'm writing this application to view the Beer Song (Song)

The output I'm getting is perfect, but the only thing wrong is that it starts from 74 not 99?!!!

here is my code:


12 years ago
that's weird, it worked! but as you said its all crushed together.

thank you so much!
14 years ago

Campbell Ritchie wrote:Welcome to JavaRanch

Please use the CODE button; since you are new I have gone back to your post and edited it, so you can see how much better it looks. Please use copy-and-paste rather than a screenshot to show your output. Click the icon on the top left of the command prompt window, then edit, then mark, then use mouse to highlight, then enter key.

I couldn't read the full output, so I copied and executed your code; the output (as you have been told) looks correct to me.

I suggest you don't put your Java work on your desktop. Next time you open a command prompt, give it the following instructions:

mkdir java
cd java

You now have a "java" directory (you can call it anything you like) which will be inside "My Documents" and you can get there easily by typing

cd java

and you can keep all your work there



That looks much better, thank you!

the code runs fine and everything, but the beginning of the output is what i'm getting wrong.

Instead of getting :

99 BOTTLES OF BEER ON THE WALL
99 BOTTLES OF BEER
etc....

I'm getting the output starting from number 60?!!! and the order of the lyrics is kinda messed up at the beginning of the output:

60 bottles of beer
Take one down.
Pass it around.
59 bottles of beer on the wall
59 bottles of beer on the wall
59 bottles of beer
Take one down.
Pass it around.
58 bottles of beer on the wall
58 bottles of beer on the wall
58 bottles of beer
Take one down.
Pass it around.






I hope my way of asking questions is better now,

thank you,
14 years ago
Hi everyone,
this is my first post here, im new to java.

Im learning java using head first 2nd edition book, and i came across this exercise which im having trouble getting the output %100 right

this is the code, and attached is the output










THANKS IN ADVANCE
14 years ago