Difference: HandsOn2325 (1 vs. 3)

Revision 32017-09-07 - JimSkon

Line: 1 to 1
 
META TOPICPARENT name="Spring2017"

Hands On Section 2.3 - 2.5

Line: 8 to 8
  1c.. Review the quality of the variable names.
Changed:
<
<
2. Square Root: The Babylonian algorithm to compute the square root of a number n is as follows:
  1. Make a guess at the answer (you can pick n /2 as your initial guess).
  2. Compute r = n / guess
  3. Set guess = (guess + r) / 2
  4. Go back to step 2 for as many iterations as necessary. The more that
steps 2 and 3 are repeated, the closer guess will become to the square root of n.

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 .

>
>
2. Square Root: The Babylonian algorithm to compute the square root of a number n is as follows:
  1. Make a guess at the answer (you can pick n/2 as your initial guess).
  2. Compute r = n / guess
  3. Set guess = (guess + r) / 2
  4. Go back to step 2 for as many iterations as necessary. The more that steps 2 and 3 are repeated, the closer guess will become to the square root of n.
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 .
 
META FILEATTACHMENT attachment="ch2.3-5.ppt" attr="" comment="" date="1485399601" name="ch2.3-5.ppt" path="ch2.3-5.ppt" size="2117632" user="JimSkon" version="1"

Revision 22017-01-26 - JimSkon

Line: 1 to 1
 
META TOPICPARENT name="Spring2017"

Hands On Section 2.3 - 2.5

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.

Changed:
<
<
1b. Make sure the indenting of the code follows the Style rule in 2.5
>
>
1b. Make sure the indenting of the code follows the Style rule in 2.5, also here.
  1c.. Review the quality of the variable names.
Line: 16 to 16
 steps 2 and 3 are repeated, the closer guess will become to the square root of n.

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 . \ No newline at end of file

Added:
>
>
META FILEATTACHMENT attachment="ch2.3-5.ppt" attr="" comment="" date="1485399601" name="ch2.3-5.ppt" path="ch2.3-5.ppt" size="2117632" user="JimSkon" version="1"

Revision 12017-01-17 - JimSkon

Line: 1 to 1
Added:
>
>
META TOPICPARENT name="Spring2017"

Hands On Section 2.3 - 2.5

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:

  1. M ake a guess at the answer (you can pick n /2 as your initial guess).
  2. Compute r = n / guess
  3. Set guess = (guess + r) / 2
  4. Go back to step 2 for as many iterations as necessary. The more that
steps 2 and 3 are repeated, the closer guess will become to the square root of n.

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 .

 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback