Lab 5. Decision
Making Structures and Loops
Points (10 overall)
Collaboration policy:
You will be working in pairs during labs.
Pairs will be randomly selected and will be announced by the TA. Each week you will have a new random
partner. You will discuss the programs
with your partner, but you will still be typing in your own code to show to the
TA. You can help each other debug, give
plenty of suggestions and hints, **explain** why things work or don't work,
etc.
To gain experience with
Write a program that allows the user to enter as many integers as they want. You will need to decide how they will tell you when they are done (remember that all integers are good input). After entering the input, the program should then output the maximum and minimum values entered.
Hints:
Read in the first value before entering the loop. Make this value the initial value of both the max and min variables.
Write a program that allows the user to enter two integers. Then print out all the values between (and including) these two integers. Do not assume that the user will enter the smallest integer first. For example, if the user enters -7 and 2, then the program would print: -7, -6, -5, -4, -3, -2, -1, 0, 1, 2. If the user enters 2 and then -7, your program would print the same values. You should error check each value that is entered to make sure that they entered the correct type (use the cin.fail() function). If the user types in bad input, your program should have them re-enter the input until it makes sense.
Write a program that allows the user to enter a value between 1 and 5 inclusive. Force them to re-enter if they enter an invalid input. Then use a loop to print out the square of the given value, then the square of the result, and so on for 4 outputs. For example, if the user entered 2, then the output would be the following;
Value Square
2 4
4 16
16 256
256 65536