King Fahd University of Petroleum and Minerals

advertisement
King Fahd University of Petroleum and Minerals
College of Computer Science and Engineering
Information and Computer Science Department
.
Quiz Number 2
ICS 201
ID:
Name:
Closed Book Quiz. You have exactly 20 minutes.
Define two Exceptions: ZeroEnteredException and NegativeValueException. Both of them
have a private variable to indicate which value caused the exception to be thrown. Also define
proper constructors for both.
Then, write a program that continues (infinitely) to ask the user to enter numbers and print
them. However, if the user enters a zero or a negative value, the program will throw the proper
exception in a try block and then stops.
ICS 201
Dr. Sami Zhioua
First Semester (101)
2010/2011
King Fahd University of Petroleum and Minerals
College of Computer Science and Engineering
Information and Computer Science Department
.
ICS 201
Dr. Sami Zhioua
First Semester (101)
2010/2011
Download