Exercise
Write a program to collect a set of numbers from the user using input and calculate the running Average of all numbers given at any instant of time. Also find the maximum value and minimum value among the numbers. User enters 'quit' to stop the calculation. Ensure that no Errors are thrown when the user does not input the expected values. Handle it gracefully by letting user know what went wrong and what the user is supposed to enter. Display the calculated values with a maximum of 2 decimal places.
Write a guessing game. When the program starts, it picks a number in random between 20-50 and keeps it in memory and asks the user to guess a number. The user inputs a number between 20 and 50, both numbers inclusive. Ensure exceptions are handled gracefully. The system will print out the following hints to help the user win:
- If the number the user input is below the number in memory by more than 10 then, print out "Your guess is too low. Try again."
- If the number the user input is below the number in memory by equal to or less than 10 then, print out "Your guess is low. Try again."
- If the number the user input is above the number in memory by more than 10 then, print out "Your guess is too high. Try again."
- If the number the user input is above the number in memory by equal to or less than 10 then, print out "Your guess is high. Try again."
Once the user guesses the correct number, then print out "Congratulations, you guessed it right in " + the number of the times the user took to guess the number correctly. If the user wants to quit the game, he can input 'quit' instead of a number and then the game ends with any message indicating the game status.