Practice Programs

Practice Programs can generally be solved with a short program that directly applies the programming principles presented in this chapter.

  1. A number x is divisible by y if the remainder after the division is zero. Write a program that tests whether one number is divisible by another number. Read both numbers from the keyboard.

  2. Write a program to read in three nonnegative integers from the keyboard. Display the integers in increasing order.

  3. Write a program that reads three strings from the keyboard. Although the strings are in no particular order, display the string that would be second if they were ...

Get Java: An Introduction to Problem Solving and Programming, 8th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.