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 Exam ReviewExam Review Arithmetic - I think everyone gets thisArithmetic.

Similar presentations


Presentation on theme: "March 2005 1/18R. Smith - University of St Thomas - Minnesota QMCS 230: Today in Class Exam ReviewExam Review Arithmetic - I think everyone gets thisArithmetic."— Presentation transcript:

1 March 2005 1/18R. Smith - University of St Thomas - Minnesota QMCS 230: Today in Class Exam ReviewExam Review Arithmetic - I think everyone gets thisArithmetic - I think everyone gets this Type casting and weird number typesType casting and weird number types Assignment statementsAssignment statements IF statementsIF statements LoopsLoops Converting from one loop to anotherConverting from one loop to another

2 March 2005 2/18R. Smith - University of St Thomas - Minnesota Exam: Reference Materials I will provide reference guidesI will provide reference guides –Java syntax basics –Reserved words you might use –Tables of details, if needed Closed book closed notesClosed book closed notes

3 March 2005 3/18R. Smith - University of St Thomas - Minnesota Exam: Questions “Inside main” questions“Inside main” questions –Assume we’ve declared the class and main –Add the declarations and statements Assume declarationsAssume declarations –Just write the statements –Assume there are variables declared already Find the errorFind the error Rewrite this code to do something elseRewrite this code to do something else

4 March 2005 4/18R. Smith - University of St Thomas - Minnesota Type casting and weird number types When do you WANT a double?When do you WANT a double? –When losing the fraction is bad When do you WANT an int?When do you WANT an int? –When you are only counting whole things Ints beget Ints EXCEPT when?Ints beget Ints EXCEPT when? Floats beget floats. Period.Floats beget floats. Period. Ints and floats yield floats.Ints and floats yield floats.

5 March 2005 5/18R. Smith - University of St Thomas - Minnesota Assignment statements They are individual boxes, cups, trays…They are individual boxes, cups, trays… –Each holds ONE object, no more and no less. Keep as few as possibleKeep as few as possible –REMEMBER what is in them - keep track! –The rule of 5 plus or minus 2 Program progress -> changes to variablesProgram progress -> changes to variables –If you know how they are changing, you know what’s happening –If you DON’T know, then you will lose track.

6 March 2005 6/18R. Smith - University of St Thomas - Minnesota IF statements Two or Three PartsTwo or Three Parts Two Parts - simple IFTwo Parts - simple IF –Part 1 = the condition –Part 2 = the statement performed when condition is true Three PartsThree Parts –Same part 1 and 2 –Part 3 = ELSE to perform if condition is false

7 March 2005 7/18R. Smith - University of St Thomas - Minnesota Loops 3 types3 types You can use Ifs to convert between themYou can use Ifs to convert between them What do you use for a “counting” loop?What do you use for a “counting” loop? What do you use if you want to do the loop contents at least once?What do you use if you want to do the loop contents at least once? What if you might want to skip the loop completely in some cases?What if you might want to skip the loop completely in some cases?

8 March 2005 8/18R. Smith - University of St Thomas - Minnesota Choosing Loops Counting LoopCounting Loop –Usually the FOR loop –Especially if you need the count number ‘inside’ Do the loop at least onceDo the loop at least once –Do While is the perfect choice - skip an extra ‘test’ –While is almost as good Possibly skip the loopPossibly skip the loop –While is the perfect choice - always tests first –Or put a ‘Do while’ inside an IF statement - extra test

9 March 2005 9/18R. Smith - University of St Thomas - Minnesota Converting from one loop to another Group of 4 => For loopGroup of 4 => For loop For loop => While loopFor loop => While loop While loop => Do While loopWhile loop => Do While loop

10 March 2005 10/18R. Smith - University of St Thomas - Minnesota Group Work 8 groups - 4 problems8 groups - 4 problems ALL: average “x” numbers read from keyboardALL: average “x” numbers read from keyboard Different problemsDifferent problems –Use ‘for’ loop –Use ‘do while’ loop –Use ‘while’ loop

11 March 2005 11/18R. Smith - University of St Thomas - Minnesota That’s it. Questions?Questions? 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.

12 March 2005 12/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 Exam ReviewExam Review Arithmetic - I think everyone gets thisArithmetic."

Similar presentations


Ads by Google