March /18R. Smith - University of St Thomas - Minnesota QMCS 230: Today in Class About HomeworkAbout Homework Increment/DecrementIncrement/Decrement While LoopWhile Loop
March /18R. Smith - University of St Thomas - Minnesota About Homework Some via , some on paperSome via , some on paper –Check the instructions for details –Each week: smaller one on paper; larger one ed 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
March /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!
March /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
March /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
March /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
March /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 or send a letter to Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA.