luck, db
There are no new questions, but there may be new answers.
Patricia Andersen wrote:Hi guys, id just want to know if there is a need for a 3rd for loop in my program with variable index in order to compare 2 arrays elements index against index or do i need to change one of the loops ive already got.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Darryl Burke wrote:First, you don't need to assign elements of a newly created numeric array to zero; they already have that value by default.
In a single loop, you can assign the current index of lotteryNumbers to a random int and test the equality of that with an int obtained from user input, thus eliminating the need for the userNumbers array. You can break out of the loop when a mismatch is detected.
Winston Gutkowski wrote:
Patricia Andersen wrote:Hi guys, id just want to know if there is a need for a 3rd for loop in my program with variable index in order to compare 2 arrays elements index against index or do i need to change one of the loops ive already got.
I'd say the first, because it's more flexible.
However, I really think you're hamstringing yourself by putting eveything in main(). It's really not a good habit to get into. For an alternative approach have a look at my MainIsAPain page.
This is the second or third thread that you've posted, and I don't get any sense that you've heeded previous advice to break problems down into small chunks and methods. Your main() method still looks like a stream of consciousness - and believe me, it's a bad way to program.
Even if you don't use the methodology suggested in the above link, at least read the StopCoding (←click→) and WhatNotHow pages.
HIH
Winston
Patricia Andersen wrote:
Winston Gutkowski wrote:
Patricia Andersen wrote:Hi guys, id just want to know if there is a need for a 3rd for loop in my program with variable index in order to compare 2 arrays elements index against index or do i need to change one of the loops ive already got.
I'd say the first, because it's more flexible.
However, I really think you're hamstringing yourself by putting eveything in main(). It's really not a good habit to get into. For an alternative approach have a look at my MainIsAPain page.
This is the second or third thread that you've posted, and I don't get any sense that you've heeded previous advice to break problems down into small chunks and methods. Your main() method still looks like a stream of consciousness - and believe me, it's a bad way to program.
Even if you don't use the methodology suggested in the above link, at least read the StopCoding (←click→) and WhatNotHow pages.
HIH
Winston
thanks for advice though
Patricia Andersen wrote:All i asked for is if there is a need for a 3rd loop. And i am trying to break the problem down into small chunks which is why i wonder if there is a need for a 3rd loop.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Winston Gutkowski wrote:
Patricia Andersen wrote:All i asked for is if there is a need for a 3rd loop. And i am trying to break the problem down into small chunks which is why i wonder if there is a need for a 3rd loop.
But:
You still have only one method, and it's static. You're thinking about things like loops, which is the how, when what you should be concentrating on is understanding what needs to be done.
If you just want answers, you're probably better off with a site like Stackoverflow. Here, we try to help you.
Winston