Programming Exercises
1: | Implement the necessary exception handling code in Listing 19.1 to prevent the program from stopping abruptly and allow (in a user-friendly manner) the user to assign a value to yourInt in Method2.
Programming exercises 2–4 build on the same program, so please save the program in each exercise. |
2: | Write a class called Meteorologist that contains an array named rainfall containing 12 elements (of type int). Write a constructor for the class that assigns an arbitrary number to each of the 12 elements in rainfall. Include a method with the following header in Meteorologist:
public int GetRainfall(int index) This method must return the value of the element in rainfall that corresponds to the given index. Include the necessary ... |
Get C# Primer Plus now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.