Chapter 1

<< Chapter 14 | HomeworkTrailIndex | Magpie Lab >>

I recommend two (or three) bookmarks while reading Horstmann

  1. Current page you are reading
  2. End of the chapter you are reading which has the answers to the Self-Check Answers
  3. Appendix C

After reading Chapter 1 and answering the Self-Check Questions, try writing your first program:

Do Exercise R1.12 on page 30. Here is some starter code to help:


public class R1_12a
{
   public static void main( String[] args)
   {
       System.out.println("3+4");
   }
}

Once you think you are a Chapter 1 Expert, try the Multiple Choice Questions in Frances Tree's Chapter2.

Demo: P1.1 NamePrinter.java

public class NamePrinter
{
    public static void main (String[]  args)
    {
        System.out.println("+-----------------+");
        System.out.println("|Go Golden Knights|");
        System.out.println("+-----------------+");

    }
}

For 8 points: Exercise P1.2 on page 30

public class FacePrinter
{
    public static void main (String[]  args)
    {

        //your work here
        . . . 

    }
}

For 9 Points Exercise P1.8 (DialogViewer) on Page 31. You have to type this one in yourself, so no starter code!

For 10 Points: Project 1.1 (GUI Question and answer) page 31 This is based on P1.8, so no starter code!

For 11 (out of 10) points, Excercse P1.6 on page 31. The correct answer of the sum 1/1+1/2+ ... +1/10 is 7381/2520. Your job is to write a program to compute this, not merely display this.

public class Sum10Reciprocals
{
    public static void main (String[]  args)
    {
        double x;
        //your work here
         . . .
        System.out.println("1/1+1/2+...+1/10 = "+x);
        System.out.println("Expected 7381/2520 or 2.92897");

    }
}