O'Reilly logo

C# Primer Plus by Klaus Michelsen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required