Generation

generate functionThu, 27 Apr 2023

Having as input data the height (h) of a person, build an algorithm that calculates their ideal weight, using the following formulas: For men: (72.7h) - 58 For women: (62.1h) - 44.7

double idealWeight(double height, char sex) { switch (sex) { case 'M': case 'm': return (72.7 * height) - 58; break; case 'F': case 'f': return (62.1 * height) - 44.7; break; default: return 0.0; break; } }

Questions about programming?Chat with your personal AI assistant