1. **Tonnage**: A metric ton is 35,273.92 ounces. Write a program that will read the weight of a package of breakfast cereal in ounces and output the weight in metric tons as well as the number of boxes needed to yield 1 metric ton of cereal. Your program should allow the user to repeat this calculation as often as the user wishes.

1b. Make sure the indenting of the code follows the Style rule in 2.5

1c.. Review the quality of the variable names.

2. **Square Root**: The Babylonian algorithm to compute the square root of a number n is as follows:

- M ake a guess at the answer (you can pick n /2 as your initial guess).
- Compute r = n / guess
- Set guess = (guess + r) / 2
- Go back to step 2 for as many iterations as necessary. The more that

Write a program that inputs a double for n and iterates through the Babylonian algorithm 100 times. For a more challenging version, iterate until guess is within 1% of the previous guess, and outputs the answer as a double .

Copyright © 2008-2020 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.

Ideas, requests, problems regarding TWiki? Send feedback

Ideas, requests, problems regarding TWiki? Send feedback