Home Segments Top Top Previous Next

400: Practice

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