/***************************************** The Bouncing Ball Inputs: initial height, bounce ratio, cutoff height Outputs: total distance traveled and number of bounces Author: Roger Hartley ****************************************/ #include int main() { int nBounces; float initHeight, height, distance, cutoff, bounceRatio; printf("Initial height? "); scanf("%f", &initHeight); printf("Ratio? "); scanf("%f", &bounceRatio); printf("Cutoff? "); scanf("%f", &cutoff); nBounces = 0; height = initHeight; distance = initHeight; while (height > cutoff) { height *= bounceRatio; distance += 2 * height; ++nBounces; } printf("The ball bounced %d times\nand traveled %f ft.\n", nBounces, distance); return 0; }