C# programming

  • Thread starter Thread starter Artim Atokpas
  • Start date Start date
A

Artim Atokpas

Guest
How to solve this?



ArgumentException is an existing class that derives from Exception; you use it when one or more of a method’s arguments do not fall within an expected range. Create a class named CarInsurance containing variables that can hold a driver’s age and state of residence. Within the class, create a method that accepts the two input values and calculates a premium. The premium base price is $100 for residents of Illinois (IL) and $50 for residents of Wisconsin (WI). Additionally, each driver pays $3 times the value of 100 minus his or her age. If the driver is younger than 16, older than 80, or not a resident of Illinois or Wisconsin, throw an ArgumentException from the method. In the Main() method of the CarInsurance class, try code that prompts the user for each value. If the user does not enter a numeric value for age, catch a FormatException and display an error message. Call the method that calculates the premium and catch the potential ArgumentException object.

Continue reading...
 
Back
Top