CIS 150 Lab: Functions, input validation

Objectives

  • Write user-defined functions
  • Use user-defined functions
  • Validate user input

Requirements

Modify the supplied program (functionLab.cpp) to make it work properly.

Example run of program

Enter the miles driven (1-600): -2 Error: The minimum value is 1 Enter the miles driven (1-600): 650 Error: The maximum value is 600 Enter the miles driven (1-600): 345 Enter the gallons used (1-50): 14.5 Your mileage specs are Miles: 345.00 Gallons: 14.50 MPG: 23.79 Time: 5.75 Press enter to continue...

Rubric

  • 4 points: for getting the function that gets a double working properly and using it
  • 2 points: for getting the function that calculates the mpg working properly and using it
  • 2 points: for getting the function that calculates the mph working properly and using it
  • 2 points: for getting the function that displays the results working properly and using it