Chapter

Normalizing a Number

From ComputerScienceOne by Dr Chris Bourke

Concepts

  1. How does an enhanced for loop calculate the sum of integers in a Java list?

    "List<Integer> list = Arrays.asList(10, 20, 8, 42);\n\nint sum = 0;\n\nfor(Integer a : list) {\n\nsum += a;\n\n}\n\nCode Sample 28.6.: Enhanced For Loops in Java Example 2"

  2. How can a while loop normalize a number by repeatedly dividing it by 10?

    "Let’s revisit the example from Section 4.1.1 in which we normalize a number by continually dividing it by 10 until it is less than 10. The code in Code Sample 28.7 specifically refers to the value 32

  3. How can a Java for loop be generalized to sum integers up to another variable?

    "Let’s revisit the example from Section 4.2.1 in which we computed the sum of integers 1 + 2 + · · · + 10. The code is presented in Code Sample 28.8 We could have easily generalized the code somewhat.

Normalizing a Number | ComputerScienceOne | Bifalgorithm | Bifalgorithm