While Loops
1) Write a program to keep asking for a number until you enter a negative number. At the end, print the sum of all entered numbers.
2) Write a program to ask for a name until the user enters END. Print the name each time. When you are done, print "I am done."
3) Test Average problem: (on powerpoint for while loops)
4) Nim problem: (on powerpoint for while loops) -- this is extra, not necessary
1. Print the instructions
2. Set the number of stick at 7 and initialize other values
3. Find out if the user wants to go first or second
4. If the user goes second, have the computer take two sticks and the user goes second, have the computer take two sticks.
5. As long as there is no winner, keep playing5.1 While there is no winner
5.2 Find out how many sticks the user is taking
5.3 Make sure its a valid choice
5.3.1 Make sure the user picked 1, 2, or 3 sticks
5.3.2 Make sure that user didnt take more sticks than are
on the table
5.4 Pick up the appropriate number of sticks.
5.5 Take the sticks off the table
5.6 See if there is a winner