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 IF StatementIF Statement Revisiting assignment statementsRevisiting.

Similar presentations


Presentation on theme: "March 2005 1/18R. Smith - University of St Thomas - Minnesota QMCS 230: Today in Class IF StatementIF Statement Revisiting assignment statementsRevisiting."— Presentation transcript:

1 March 2005 1/18R. Smith - University of St Thomas - Minnesota QMCS 230: Today in Class IF StatementIF Statement Revisiting assignment statementsRevisiting assignment statements Prep for Lab 5Prep for Lab 5

2 March 2005 2/18R. Smith - University of St Thomas - Minnesota IF Statements What’s the idea? Skipping stepsWhat’s the idea? Skipping steps Syntax: if (test) thing-to-do;Syntax: if (test) thing-to-do; –If test fails, thing-to-do is skipped –If it succeeds, it’s executed Relational operatorsRelational operators – and = –== and !=

3 March 2005 3/18R. Smith - University of St Thomas - Minnesota Examples Rectangle x and y valuesRectangle x and y values –make them the right order to calculate lengths Solving the problemSolving the problem –Identify what you have to calculate –Create one “result” variable for each calculation –Decide if you have to ‘accumulate’ results –Step through the calculation, filling in the variables

4 March 2005 4/18R. Smith - University of St Thomas - Minnesota Boat Problem: Almost Lab 5 Custom boat: collect the length and width, number of seatsCustom boat: collect the length and width, number of seats Length is at least 3x width, fix width if wrongLength is at least 3x width, fix width if wrong Length is no more than 5x width, fix width if wrongLength is no more than 5x width, fix width if wrong Number of seats is no more than 1/3 lengthNumber of seats is no more than 1/3 length Cost per seat is $53Cost per seat is $53 Boat’s cost is L x W x $87 + cost of seatsBoat’s cost is L x W x $87 + cost of seats

5 March 2005 5/18R. Smith - University of St Thomas - Minnesota Overview of Lab 5 Calculating size and cost of custom shelvingCalculating size and cost of custom shelving Collect shelf length and total lengthCollect shelf length and total length Fix the shelf length to meet the constraintsFix the shelf length to meet the constraints Calculate the # parts you need, rounding upCalculate the # parts you need, rounding up

6 March 2005 6/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 IF StatementIF Statement Revisiting assignment statementsRevisiting."

Similar presentations


Ads by Google