From the course: C# Exception and Error Handling

Unlock the full course today

Join today to access over 24,800 courses taught by industry experts.

Challenge: Custom exceptions

Challenge: Custom exceptions - C# Tutorial

From the course: C# Exception and Error Handling

Challenge: Custom exceptions

- [Instructor] Okay, let's try another programming challenge. For this challenge, you're going to implement a coin counting program, and you might have seen machines that do this in one of your local stores. You put your coins in the machine and it counts them for you. So we're going to build that. And here is the starting point for the challenge. This array of strings will represent the test input to your code. Your program will then be called using this logic. So we're going to create the CoinCounter class, which you're going to implement. And then for each one of the coins in the test coin array, we're going to call the CountCoin method with that coin. You're going to total up all the coins, and then you're also going to maintain a list of bad inputs and write those out to the console when your program is done. Because sometimes people put things in the machine that are not valid coins, and you can see examples of that here in the list, like a washer and medallion and so on. So…

Contents