From the course: Debugging in C#

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Logical code challenge

Logical code challenge

From the course: Debugging in C#

Start my 1-month free trial

Logical code challenge

(upbeat music) - [Woman] Let's tackle another debugging code challenge. For this challenge, we have some code that attempts to find the BMI, or body mass index, for each patient in a collection of patients. Where each patient has a weight and height value. Right now, this code does not work, due to several logical errors, but let's walk through it's structure. Starting with the main method, we create a tuple of patients, with the initialize patients function. Jumping up, to this function we have a tuple as our return value, initialize patients, and we want to initialize a number of patients, and so whether it's ten or twenty, this is going to be the number of patients we decide to initialize in the array. So, first, we create a set of patients, but then we also add some edge cases. So we have some edge cases up here, or what if, y'know, there's a patient with a zero height and a zero weight, or negative height and negative weight. So these doubles in here are the height and weight of…

Contents