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 MethodsMethods Problem solving by decompositionProblem solving by.

Similar presentations


Presentation on theme: "March 2005 1/18R. Smith - University of St Thomas - Minnesota QMCS 230: Today in Class MethodsMethods Problem solving by decompositionProblem solving by."— Presentation transcript:

1 March 2005 1/18R. Smith - University of St Thomas - Minnesota QMCS 230: Today in Class MethodsMethods Problem solving by decompositionProblem solving by decomposition

2 March 2005 2/18R. Smith - University of St Thomas - Minnesota Methods Revisited How was Lab 11?How was Lab 11? What problems did people have?What problems did people have? Quick group thing – groups of 3 or 4Quick group thing – groups of 3 or 4 –What problems did you have with Lab 11? –Make a list –Appoint a spokesperson

3 March 2005 3/18R. Smith - University of St Thomas - Minnesota Problems How to get variables into a methodHow to get variables into a method Using variables in a methodUsing variables in a method Confusing that print stub was before the loopConfusing that print stub was before the loop Calling methodsCalling methods Keeping track of changes while moving things aroundKeeping track of changes while moving things around You have to both declare the method and call itYou have to both declare the method and call it After running one method, how to call the next one Making integer day of week into “Monday” etc. While loop for the hours

4 March 2005 4/18R. Smith - University of St Thomas - Minnesota Day of week For (I = 1; I<6; I++) {For (I = 1; I<6; I++) { –System.out.println(“Hours for “+ dayOfWeek(I) + “: “);dayOfWeek(I) + “: “);

5 March 2005 5/18R. Smith - University of St Thomas - Minnesota dayOfWeek(int I) { String Answer = “??”; If (I == 1) Answer = “Monday”; Else If (I == 2) Answer = “Tuesday”; Return Answer; }

6 March 2005 6/18R. Smith - University of St Thomas - Minnesota Problem solving It takes a lot of statements to write a useful programIt takes a lot of statements to write a useful program Solve the problem in steps – each step can be a method in JavaSolve the problem in steps – each step can be a method in Java Then write the individual methodsThen write the individual methods

7 March 2005 7/18R. Smith - University of St Thomas - Minnesota Batch Payroll Goal: do payroll from a fiileGoal: do payroll from a fiile Pieces/ MethodsPieces/ Methods –Main Opens the ‘timesheet’ fileOpens the ‘timesheet’ file Loop through timesheetsLoop through timesheets –Accumulate gross pay for employer Print employer obligationsPrint employer obligations –One to do one employee – returns gross pay Check for overtime approvalCheck for overtime approval Collect 5 days of hoursCollect 5 days of hours Calculate gross payCalculate gross pay Call printStubCall printStub –Print paystub for one employee –Print employer tax obligations

8 March 2005 8/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.


Download ppt "March 2005 1/18R. Smith - University of St Thomas - Minnesota QMCS 230: Today in Class MethodsMethods Problem solving by decompositionProblem solving by."

Similar presentations


Ads by Google