Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

>> REGISTER NOW TO START POSTING

# Thread: Help With Flowchart (Non-Code Issue)

1. ## Help With Flowchart (Non-Code Issue)

Hello everyone and Good Morning! In learning about Counters and Accumulators, I have been given the task to create a flowchart that does the following:

"Ask the user for a positive, whole number > 0, call it x. Output all the numbers from 1 up to x."

I have a few flowcharts written out that don't quite do what I want them to do when I desk-check them. I could use a little help/ a nudge in the right direction (As this forum is filled with people who tend to do just that, and only that *no offense*)

A flowchart I have created goes as follows in descending order:

Start
(Counter) outX = outX + 0
Output - "Enter positive whole number"
Input - x

Decision (outX = x)?

-No- (x = x -1) (outX = outX + 1) >>>>>>>> Output " outX " >>>> Loop back to decision

-Yes- Output "outX, x"

Stop

I know this is very basic and I am missing something, but I don't quite know what. Any help or advice would be greatly appreciated.

2. ## Re: Help With Flowchart (Non-Code Issue)

A few questions:
1. Why have you initialized your counter to outX + 0? Why not just 0?
2. I don't know if it would be part of your requirements, but in a real-life situation, you would want to varify that the user did in fact give you a number > 0. Just because you tell a user to do something, doesn't mean they actually will.
3. Why are you decrementing x in your loop? If you subtract x by 1 and add outX by 1, you are technically advancing the counter by 2 since you do an equals check with outX and x (and, if x is odd, you will pass right by the value since they will never equal each other).