CIS 150 Programming Project: Functions, input validation

Objectives

  • Create user-defined functions
  • Use user-defined functions
  • Validate user input
  • Create function prototypes
  • Implement pseudocode

Overview

This assignment gets a start value and an end value from the user. Both values must be validated as integers within specified ranges. The program then displays a list of all the prime numbers between those two values.

General program requirements

  1. Add documentation comments to the start of your program, including file name, course, your name, the date, and a brief description of the purpose of the program.
  2. Include the needed libraries: cmath, iostream, sstream, and string
  3. Create prototypes for the two functions that you will implement after main (getInt and isPrime).

Pseudocode for main function

Pseudocode for getInt function

Pseudocode for isPrime function

Sample Run

Enter starting integer (1 - 100): SpongeBob SquarePants Error: Invalid integer Enter starting integer (1 - 100): -4 Error: Value below minimum of 1 Enter starting integer (1 - 100): 700 Error: Value above maximum of 100 Enter starting integer (1 - 100): 1 Enter ending integer (2 - 1000): 1 Error: Value below minimum of 2 Enter ending integer (2 - 1000): Patrick Star Error: Invalid integer Enter ending integer (2 - 1000): 123 Primes between 1 and 123 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 103 107 109 113

Rubric

  • 3 points for proper documentation comments and for correctly following coding conventions (indentation, naming rules, NO tabs, NO global variables, etc.)
  • 2 points for having the correct function prototypes
  • 5 points for having the main function working properly
  • 10 points for having the getInt function working properly
  • 10 points for having the isPrime function working properly