Presentation is loading. Please wait.

Presentation is loading. Please wait.

March 2005 1/18R. Smith - University of St Thomas - Minnesota QMCS 230: Today in Class About HomeworkAbout Homework Increment/DecrementIncrement/Decrement.

Similar presentations


Presentation on theme: "March 2005 1/18R. Smith - University of St Thomas - Minnesota QMCS 230: Today in Class About HomeworkAbout Homework Increment/DecrementIncrement/Decrement."— Presentation transcript:

1 March 2005 1/18R. Smith - University of St Thomas - Minnesota QMCS 230: Today in Class About HomeworkAbout Homework Increment/DecrementIncrement/Decrement While LoopWhile Loop

2 March 2005 2/18R. Smith - University of St Thomas - Minnesota About Homework Some via e-mail, some on paperSome via e-mail, some on paper –Check the instructions for details –Each week: smaller one on paper; larger one e-mailed Formatting and commenting!Formatting and commenting! –Programs are hard to read anyway –My requirements are simple but inflexible –Indenting for every curly brace, IF-ELSE, or loop –Comment on every 2-5 statements –Comment on every variable declaration Complying with instructionsComplying with instructions –Be sure you understand the instructions –Specific instructions must be followed

3 March 2005 3/18R. Smith - University of St Thomas - Minnesota Increment/Decrement Double plus or double minusDouble plus or double minus Attached to an integer variableAttached to an integer variable –Short, byte, long, int… Super experts: feel free to read p. 178Super experts: feel free to read p. 178 Everyone else:Everyone else: DO NOT USE THESE IN EXPRESSIONS OR Conditionals!DO NOT USE THESE IN EXPRESSIONS OR Conditionals!

4 March 2005 4/18R. Smith - University of St Thomas - Minnesota While Loop Loops are how we get things doneLoops are how we get things done –Repeat a bunch of instructions, doing things a bit more or a bit differently each time Loops are the Last Big ThingLoops are the Last Big Thing –If you have: LoopsLoops IFIF AssignmentsAssignments CalculationsCalculations –You can do any calculation you want Indenting RuleIndenting Rule –Like an IF statement

5 March 2005 5/18R. Smith - University of St Thomas - Minnesota WHILE Details “while” (condition - like in an IF)“while” (condition - like in an IF) –{ Statements to executeStatements to execute At least one should affect the conditionAt least one should affect the condition –Or the loop never ends –} ExamplesExamples –Counting up –Counting down –Infinite loop –Fixing input

6 March 2005 6/18R. Smith - University of St Thomas - Minnesota Lab 7 Based on the Shelving LabBased on the Shelving Lab Write a loop that, if the input is wrong, will collect different input until correct input is receivedWrite a loop that, if the input is wrong, will collect different input until correct input is received Use remainder/mod to get precise calculationsUse remainder/mod to get precise calculations PRINT OUT THE JAVA Code.PRINT OUT THE JAVA Code. HAND IN ONLY the JAVA CodeHAND IN ONLY the JAVA Code

7 March 2005 7/18R. Smith - University of St Thomas - Minnesota Creative Commons License This work is licensed under the Creative Commons Attribution-Share Alike 3.0 United States License. To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/3.0/us/ or send a letter to Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA.


Download ppt "March 2005 1/18R. Smith - University of St Thomas - Minnesota QMCS 230: Today in Class About HomeworkAbout Homework Increment/DecrementIncrement/Decrement."

Similar presentations


Ads by Google