This week's giveaway is in the Beginning Java forum.
We're giving away four copies of Bad Programming Practices 101 (e-book) and have Karl Beecher on-line!
See this thread for details.
Win a copy of Bad Programming Practices 101 (e-book) this week in the Beginning Java forum!

Ashish Dutt

Ranch Hand
+ Follow
since Apr 12, 2013
Ashish likes ...
Java MySQL Database Python
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
8
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Ashish Dutt

Hello,
Welcome to the Java Ranch
You can refer to this webpage
4 years ago
You are quite near to the solution. As Winston rightly says, "Forget coding for now, Take a pencil and paper and write what the program is supposed to do", and that's what you have to do now. You have rightfully figured out the problem that the existing code does not repeat itself. Now you have to think of two issues;
1. After the first factorial is computed, the program code is supposed to prompt
the user for a choice to continue or not. If the choice is Yes, then the block of
code that accepts the user input should repeat again. So your clue here is to
figure out how to make the code loop and ask for another input.
2. Remember to reassign the variable factorial to a default value because if you
do not then with the next user input, the variable factorial will start its computation
from the previous value stored in it. Example:
Lets say when the
program first executed, the user entered 3 so the factorial was computed to
3x2x1=6, Now if the user wants to calculate another factorial and you do not
assign it a default value then previous factorial value will be computed for the
current cycle. So if variable factorial is not assigned a default value and user
enters 5 then the new factorial will be 6x5x4x3x2x1=720
Hope this helps.
4 years ago
Ohh please, dont say 'sorry' about it. Its a natural phenomenon. I made the same mistake when i first came here.
4 years ago
Hello Jill,
Welcome to the Java Ranch.
Please use code tags to post your code because that renders it to be readable, i have done it for you now.
4 years ago
Hello Michael,
Welcome to the Java Ranch.
That's an interesting problem however the next time when you post a problem please provide details on 'what is the problem that you are experiencing?'
Gauging by the code and the question that you have posted, I can see some obvious problems.
My suggestion to you would be to study the modulus operator for that is the key to this problem. Modulus Operator
4 years ago
You are welcome, Declan. We are happy that you were able to figure out the problem and resolve the issue.
4 years ago
A quick google search could have helped you here, the keyword to search for is "MOOC tools"
I found some links that you may find useful
CourseBuilder
ELI
The MOOC Guide
Welcome to Java Ranch.
The problem definitely lies in that JComBox constructor because of the parameter that you are passing it.There had been a similar previous post; http://www.coderanch.com/t/618985/GUI/java/line-wrong-program-constructor-undefined, and this link Linkfrom Oracle docs might help you.
4 years ago
Hello,
Do let us know what have you tried so far?
4 years ago
See, list contains the elements of the array in this case its 4 elements and then you are using a for loop which loops from index 0 till index 3 and it keeps printing the list elements. According to your requirement you desire individual list elements to be popped out and for that perhaps this link http://docs.oracle.com/javase/6/docs/api/java/util/ArrayList.html might help you.
4 years ago
Hello,
I just wanted to make a correction to your code that i'm certain you forgot to write, but its ok. Line 17 should actually be
Well, when i ran the corrected code, i get the following output as follows
[code=java]
4 years ago
Hello Chris,
Welcome to Java Ranch.
I'm glad to know that your program worked however the reason for writing this is to highlight

what i try to do is compile my class

javac MyFirstClass.java

while your program is named MyFirstApp, i wonder how did it even compile on rebooting your computer, but if it did its good :-)
4 years ago
Hello Salma,
Welcome to java ranch.
I would recommend if you could post the full code including the main method reason being its hard to deduce what does the variable arr[] stores from the code that you have posted.
4 years ago

Winston Gutkowski wrote:

Ashish Dutt wrote:Let's rewrite the code again...


Let's not.

Please DontBeACodeMill (←click) Ashish; especially in the 'Beginning Java' forum. I'm sure your motives were great, but we prefer people to find their own solutions.

So: by all means explain what the problem is, and help beginners; but don't spoon-feed.

Thanks.

Winston


My sincere apologies, Winston.
I forgot what i normally preach and practice.
Thanks for reminding me. :-)
4 years ago
To the Forum Moderators
I have learnt a lot from this forum and i believe that this forum is for folks who want to learn by coding and not for nincompoops who are ardent believers of the philosophy that 'money can buy everything' or 'begging for ready-made code will help ease their misery'.
Moderators, is there no way by which you could ban such folks because this forum is not for plagiarizer's who seem to be posting messages like these in abundance here?
4 years ago