While loops vs For Loops - While loops vs. For loops -...

This preview shows page 1 - 2 out of 2 pages.

The preview shows page 1 - 2 out of 2 pages.
While loops vs. For loops-while statements check conditions-for loops have a set quantity-syntax differenceowhile: increments in loopofor: increment specified, all conditions initialized in statementVolume in forLoop-loop through samples in array-double value-> double amplitude of sound-make method more generalouse parameter to decide how much to change volumeodon’t use integer but use doubleDoubles to Ints-can’t assign value of double to a variable of type int-result of an integer times a double is a doubleo(value*factor)-need to cast from double to integerouse (int)(value*factor)ocasting gets rid of fractionsCalling a Method from a Method-have decreaseVolume and increaseVolume call changeVolumeouse this.changeVolume OR changeVolumeinvokes method on current object“this” is implicitForce to Extremes-make sounds maximum positive or negative valuesovia a 16 bit soundoif the value is 0 or positive make it 32,767oif the value is negative make it -32, 768-

Upload your study docs or become a

Course Hero member to access this document

End of preview. Want to read all 2 pages?

Upload your study docs or become a

Course Hero member to access this document

Term
Fall
Professor
Sibert
Tags
Subroutine, Control flow, type int

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture