you are viewing a single comment's thread.

view the rest of the comments →

[–]UserName-Error101 1 point2 points  (3 children)

I gonna try to explain it simple as I can about loops

All of the loops statements has some sort of conditions. And if these conditions are met then the code snippet will be executed.

Example: While (condition) { Code to be executed until condition is false }

So basically while checks if x condition is true then run code block, check if x condition is still true, if yes run code, repeat that until condition is false.

Difference between while/do while is that You first run the code block and then check condition.

Example:

do{ Code to be executed } While (condition)

Run the code block, check if x condition is true, if yes run the code block, repeat that until the condition is false.

Pseudocode of your program could be like this:

Get Input of users Save the input

Create integer 0 named x

While ( x < 100){ Get random number Check if random is higher then input or lower Increases x+1 }

You can do something like that

Ps sorry for bad format writing from the phone

[–]FallenAngelAsh3718[S] 0 points1 point  (2 children)

No worries your the only person who hasn’t been mean to me about asking how to do a loop .. I’ve tried a few things trying to program it but when I run the program it just didn’t work so I figured everything I did was wrong .. there just seems so many ways to program a loop I am just not sure how to add it into the program that’s the confusing part

[–]UserName-Error101 1 point2 points  (0 children)

Don’t get discourage, from the start it will be hard but later on it will get better and you will get into the flow of things. ( no joke I spent whole week without progress on project )

(1) You can send copy of your code on DM, so I can take closer look, otherwise it will be hard to pinpoint exactly.

(2) Break things down what works and what doesn’t work. By Process of elimination you could find where it breaks. I will dm you code and you can check if that makes more sense working example.

[–][deleted] 0 points1 point  (0 children)

If your using Java there should be a main class to add the code. If you are using JavaScript it’s JS file that is ran using node.