Big Java 5

Chapter 1 – Introduction

Computer Programs

Self Check 1.1

What is required to play a music CD on a computer?

Self Check 1.2

Why is a CD player less flexible than a computer?

Self Check 1.3

What does a computer user need to know about programming in order to play a video game?

Class Question Jan 23 - 1

Where is a program like Microsoft Word usually stored when it is not currently running?

  1. On the printer
  2. On a memory stick
  3. On a hard drive
  4. In the cloud

The Java Programming Language

Becoming Familiar with Your Programming Environment

Becoming Familiar with Your Programming Environment

  1. Start the Java development environment.
  2. Write a simple program.
  3. Run the program.
  4. Organize your work

Becoming Familiar with Your Programming Environment

 

From Source Code to Running Program

Figure 7 From Source Code to Running Program

Self Check 1.10

What do you do to protect yourself from data loss when you work on programming projects?

In the real world

Analyzing Your First Program: Methods

Analyzing Your First Program: main Method

Analyzing Your First Program: Statements

Analyzing Your First Program: Method Call

Syntax 1.1 Java Program

syntax diagram

Analyzing Your First Program: Strings

Analyzing Your First Program: Printing

Class Question Jan 28 - 1

How do you modify the HelloPrinter program to greet you if your name is Carlos
  1. System.out.println(Hello, Carlos);
  2. System.out.println("Hello, Carlos");
  3. system.out.println("Hello, Carlos");
  4. System.print("Hello, Carlos");

Class Question Jan 28 - 2

What does the following set of statements print?
System.out.print("My lucky number is");
System.out.println(3 + 4 + 5);
  1. My lucky number is 12
  2. My lucky number is12
  3. My lucky number is
    12
  4. It does not print anything. There is a syntax error

Errors

Errors

Class Question Jan 28 - 3

Suppose you omit the "" characters around Hello, World! from the HelloPrinter.java program. Is this a compile-time error or a run-time error?
  1. compile-time
  2. run-time
  3. It is not an error

Class Question Jan 28 - 4

Suppose you change println to printline in the HelloPrinter.java program. Is this a compile-time error or a run-time error?
  1. compile-time
  2. run-time
  3. It is not an error

Class Question Jan 28 - 5

Suppose you change main to hello in the HelloPrinter.java program. Is this a compile-time error or a run-time error?
  1. compile-time
  2. run-time
  3. It is not an error

Class Question Jan 28 - 6

When you used your computer, you may have experienced a program that "crashed" (quit spontaneously) or "hung" (failed to respond to your input). Is that behavior a compile-time error or a run-time error?
  1. compile-time
  2. run-time
  3. It is not an error

Notes

Problem Solving: Algorithm Design

An Algorithm for Solving an Investment Problem

An Algorithm for Solving an Investment Problem - continued

Pseudocode

From Algorithm to Programs

Program Development Process

Class Question Jan 30 - 1

Suppose the interest rate was 20 percent. How long would it take for the investment to double?

  1. 3
  2. 4
  3. 5
  4. There is not enough information to tell

Self Check 1.22

Suppose your cell phone carrier charges you $29.95 for up to 300 minutes of calls, and $0.45 for each additional minute, plus 12.5 percent taxes and fees. Give an algorithm to compute the monthly charge for a given number of minutes.

Use paper and pencil

Self Check 1.23

Consider the following pseudocode for finding the most attractive photo from a sequence of photos:
Pick the first photo and call it "the best so far".
For each photo in the sequence
   If it is more attractive than the "best so far"
      Discard "the best so far".
      Call this photo "the best so far".
The photo called "the best so far" is the most attractive photo in the sequence. 

Use pencil and paper

Is this an algorithm that will find the most attractive photo?

Self Check 1.24

Suppose each photo in Self Check 23 had a price tag. Give an algorithm for finding the most expensive photo

Use pencil and paper

Self Check 1.26

Suppose you have a random sequence of colored marbles. Consider this pseudocode:
Repeat until sorted
   Locate the first marble that is preceded by a marble of a different color, and switch them.
Why is this not an algorithm?