CpSc 146 Assignment 4 -- Repetition Programming

The discussion on this page is meant to assist you with designing your solution - it is a guide on how to organize the program


Part 1 - Top level code; will become the final solution
  1. Write the code for the 4 menu options and get the option from the user
  2. Write a switch statement for the 4 options (the 4th option is to quit). For each case, simply cout which option was chosen
  3. Test the code you wrote.
  4. Place the tested code inside a do while loop that ends when option 4 is chosen
    Your code should resemble this code
  5. Test the code

Part 2 - Counting up code
  1. Start a new program
  2. Ask the user for the end number (N) and the increment (step)
  3. If N is below 1, output an error message, otherwise:
  4. Using a for loop, count from 1 to N by step
  5. Test your code
  6. Once it is working, copy the code into case 1 of the final solution
  7. Test the case 1 of the final solution

Part 3 - Counting down code
  1. Modify the code from part 2
  2. Using a for loop, count from N downto by step
  3. Test your code
  4. Once it is working, copy the code into case 2 of the final solution
  5. Test case 2 of the final solution
  6. Re-test case 1 of the final solution

Part 4 - Base 2 conversion
  1. Start a new program
  2. Request an integer number between 1 and 1,000 from the user
  3. If the number is out of range, output an error message. Otherwise
  4. Compute the binary equivalent of the number using the code from class
  5. Test the code
  6. Once it is working, copy the code into case 3 of the final solution
  7. Test case 3 of the final solution
  8. Re-test case 1, and case 2 of the final solution