locked
C# programming RRS feed

  • Question

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

    Wednesday, July 8, 2020 7:08 PM

All replies

  • This is clearly a homework assignment. We do not do homework in the forums. Pleas post your code and a specific question about that code. We won't do the coding for you.

    Michael Taylor http://www.michaeltaylorp3.net

    • Proposed as answer by Naomi N Wednesday, July 8, 2020 8:29 PM
    Wednesday, July 8, 2020 7:26 PM