Sign In | Subscribe
Start learning today, and be successful in your academic & professional career. Start Today!
Loading video...
This is a quick preview of the lesson. For full access, please Log In or Sign up.
For more information, please see full course syllabus of Java
  • Discussion

  • Study Guides

  • Download Lecture Slides

  • Table of Contents

  • Related Services

Bookmark and Share
Lecture Comments (4)

1 answer

Last reply by: Kitt Parker
Fri Jul 10, 2015 1:30 PM

Post by John Bosco on July 3, 2013

Why is double in paranetheses for the section that states totalMilesPerGallon=(double) totalMiles/totalGallons; ?

0 answers

Post by Antonio Duran on April 5, 2013

for Example 1: Shouldn't the while loop be set to 5 and not 4? Otherwise, how is the program able to read the final "else if (product ==4)"?

0 answers

Post by ilonka harezi on August 5, 2011

i have had trouble in the past understanding the the use of increment and decrement operator, but through the Loop lesson, i got it. thanks you for a great teaching ability, may you have more on your plate to help those in need.


  • Loops, or repetition statements, repeat blocks of code without the programmer having to re-type them
  • Loops usually use Counters to count the number of times the loop has run
  • Counters usually use Increment and Decrement operators to add or subtract from the counter total
  • A loop “Sentinal” is a signal to the program that the loop should break
  • A continue statement skips the remaining statements in loop body and proceeds with the next iteration of the loop


Lecture Slides are screen-captured images of important points in the lecture. Students can download and print out these lecture slide images to do practice problems as well as take notes while watching the lecture.

  • Intro 0:00
  • Types of Loops 0:07
    • For Loop
    • While Loop
    • Do…While Loop
  • Increment and Decrement Operators 2:26
    • Operators Overview
    • Pre-Increment
    • Pre-Decrement
    • Post-Increment
    • Post-Decrement
  • Counters vs. Sentinels 7:06
    • Counters
    • Sentinels
  • Break & Continue Statements 8:46
    • Break
    • Continue
  • While Loop Syntax 10:03
    • While Loop Syntax and Example
  • For Loop Syntax 11:54
    • For Loop Syntax and Example
  • Example 1: Calculate Commissions for Sales Staff 13:55
  • Example 2: Program Calculates Average Miles Per Gallon 18:56
  • Example 3: Find the Smallest of Entered Numbers 23:30
  • Example 4: Return the Lyrics to 'The 12 Days of Christmas' 27:37
  • Example 5: Do While Setup 31:50
  • Example 6: Break Loop Statement Example 34:21
  • Example 7: Continue Loop Statement Example 35:05