Home Segments Index Top Previous Next

290: Practice

Write a program that transforms a patient's weight and height into one of three messages: “The patient appears to be underweight,” “The patient appears to be of normal weight,” or “The patient appears to be overweight.” Your program's input is three numbers: the first is the patient's weight in kilograms, the second is the patient's height in meters, and the third is a gender code—0 for men and 1 for women. You may assume that a patient's “perfect” weight is proportional to height, and that the overweight and underweight messages should not appear unless the patient's weight differs from the perfect weight by more than 10 percent.