Lab 2 - Basic Input Validation

The purpose of this lab is to use basic input validation which prints an error message and exits when the user gives bad input.

Review Lab 1 for how to log in to Sleipnir, edit source code and send an email.

You may work in groups of up to 3 students for this lab. Name your source code file lab2.cpp and make sure to put the names of all group members in the comment section at the top of the source code file.

Program Requirements: Print out a message that asks the user to pick a number between 1 and 10. Read in what they type on the keyboard into an integer. If they enter a number less than 1 or greater than 10, print an error message and exit the program. Otherwise, echo the number they entered to the screen, then use the sizeof function to print the size of an integer, a long integer, and a double.

Run the program multiple times to make sure you are validating the input correctly. Try entering a negative number, then try 0, then try 1, then try 10, then try 11, and so on. Testing 0, 1, 10, and 11 is called boundary testing to make sure the program behaves correctly when the input switches from bad to good (or good to bad).

Lab Submission: Email me and attach your lab2.cpp file (the source code) to the email. Do NOT email me your lab2 file (the executable). You should also CC your lab partner(s) so they have a copy of the source code.