Part 6 - Loops

This section will cover both counted and conditional loops in C#.

Loops

What to Do?

1 - Read and complete Part 6a - Counted Loops

2 - Read and complete Part 6b - Conditional Loops

2 - Complete Part 6 - Looping Programs and submit the programming assignment.

      • All of your programs at this point should be error proof.

          • Numeric conversion failures.

          • Maximums smaller than minimums.

              • An infinite loop is an error.

          • Betting more than you have

          • etc...

      • Use a menu for the different parts:

SUBMIT

    • Part 6 - Looping Problems project.

        • Use a menu to allow the user to choose a part to run:

        • 5 parts:

            • Prompter (conditional)

            • Percent Passing (counted OR conditional)

            • Odd Sum (counted)

            • Random Numbers

            • Dice Game (add a loop to the dice game you made in Part 5)

        • Unless specified, you may complete each question with either a counted or conditional loop.

        • Your programs should not crash at this point due to invalid input.

Looping Programming Assignment

Part 6 - Looping Programs.pdf

Hints, TIPS and FAQs

Q: I have seen the keyword 'continue' used in a loop. What does it mean?

A: The continue statement in a loop can be used to skip the remaining body of the loop and continue on to the next iteration. See this link for more:

Q: I have a while loop that should end in a number of different conditions and I'm struggling to come up with a conditional statement for all of these conditions.

A: Sometimes it is just easier to use a boolean variable as your condition, and the inside the loop use various if statements to check for the various conditions.

ex.

bool done = false;

while (!done)

{

// body logic of loop


if (check for end condition 1)

done = true;

if (check for end condition 2)

done = true;


...


if (check for end condition n)

done = true;

}