CIS 150 C++ Programming Project: Repetition

Objectives

  1. Use repetition
  2. Get user input
  3. Perform basic input validation
  4. Perform a calculation using a loop
  5. Display results of a calculation

Program requirements

  1. Include documentation comments at the start of the file.
  2. Follow the course style guidelines including indentation, naming conventions, spaces instead of tabs, etc.
  3. Declare integer variables for a start value, an end value, and a sum.
  4. Use a while or do/while loop to prompt the user and get an integer value between 1 and 500. If the user enters a value out of bounds, then display an error message and reprompt the user. Continue until the user enters a value within the requested range.
  5. Use a while or do/while loop to prompt the user and get an integer value between the starting value + 1 and 1000. If the user enters a value out of bounds, then display an error message and reprompt the user. Continue until the user enters a value within the requested range. The prompt must display the starting value plus one as the minimum value to be entered.
  6. Use a for loop to calculate the sum of the integers from the start value through the end value.
  7. Display the sum in a message which includes the start and end values. See the example program run for the specific format.

Points

Example run

Enter starting value for loop (1 - 500): -3
Invalid starting value.
Enter starting value for loop (1 - 500): 501
Invalid starting value.
Enter starting value for loop (1 - 500): 230
Enter ending value for loop (231 - 1000): 230
Invalid ending value.
Enter ending value for loop (231 - 1000): 1001
Invalid ending value.
Enter ending value for loop (231 - 1000): 782
The sum of the integers from 230 through 782 is 279818