Practice Programs

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

  1. Obtain a copy of the Java program shown in Listing 1.1 from the Web at the location given in the preface. Name the file FirstProgram.java. Compile the program so that you receive no compiler error messages. Then run the program.

  2. Modify the Java program described in Practice Program 1 so that it adds three numbers instead of two. Compile the program so that you receive no compiler error messages. Then run the program.

  3. The following program has syntax errors that prevents the program from compiling. Find and fix the errors.

    import java.util.Scanner;
    public class SyntaxError
    {
     public static ...

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.