Exercises

4.10Compare and contrast the if single-selection statement and the while repetition statement. How are these two statements similar? How are they different?
4.11Explain what happens when a Java program attempts to divide one integer by another. What happens to the fractional part of the calculation? How can a programmer avoid that outcome?
4.12Describe the two ways in which control statements can be combined.
4.13What type of repetition would be appropriate for calculating the sum of the first 100 positive integers? What type of repetition would be appropriate for calculating the sum of an arbitrary number of positive integers? Briefly describe how each of these tasks could be performed.
4.14What is the difference between preincrementing ...

Get Java™ How to Program, Seventh Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.