18 - Exception II (Solutions)
Ahmed
Exercises solutions
Exercise 1 - Define simple Exception to check phone number provided by the user . if the length is less than 14 digits and doesnt start with plus.
then trow InvalidPhoneNumberException
- In your
main
method, use aScanner
to get a user input, and check the above conditions
Exercise 2 - read Student properties (first name, last name, age , course) from user conole input as above throw customized exceptions in the below cases
Excercise 3 - lets create a simple (Rock, Paper, Scissor) .if you dont know the game here are the rule
- Rock beats Scissor
- Scissor beats Paper
- Paper beats Rock so the game asks the user to choose from inputs( R, P, S) and then the computer play a random choice from the three options. and the program should calculate the final result as per above ruls your program should utilize the use exceptions that we learned so far