220 likes | 339 Views
Rating a Shoe. Objectives: Explain how sequence, selection, and iteration are building blocks of algorithms Create equations with two or more variables to represent relationships among quantities. Warm-Up. R = 3 L + 3 P + 2 C + 2 F Solve for R given the following variable values:
E N D
Rating a Shoe Objectives: Explain how sequence, selection, and iteration are building blocks of algorithms Create equations with two or more variables to represent relationships among quantities.
Warm-Up R = 3L + 3P + 2C + 2F • Solve for Rgiven the following variable values: • L = 7 P = 4 C = 8 F = 6 • L = 9 P = 8 C = 7F = 4 2. Describe the relationship between variables L, P, C, & F. • Do they all affect R equally? • How does L affect R? • How does L’s effect on R compare to P’s? • How does L’s effect on R compare to C’s?
Factors for Choosing Shoes Discuss with your neighbors: What factors go into choosing a shoe?
Factors for Choosing Shoes Looks, Price, Comfort, Function
Which Shoe is Better? Shoe 1 Shoe 2 Shoe 3 Price: $180 Comfort: pretty good, a little stiff, not that cushiony Looks: multiple colors, fancy style, famous brand Function: medium weight, very durable, supportive Price: $45 Comfort: okay, loose fit, not much cushion Looks: classic, retro, many color choices, minimal styling, famous brand Function: medium weight, low durability, little support Price: $160 Comfort: very good, soft, warm Looks: simple, one color, minimal styling Function: light weight, not durable, little support
Computing a Problem • Identify Factors: Variables • Quantify: Numbers & Units • Express the Relationship: Equation • Algorithm: How my mind does it • Coded Algorithm: How computer does it
Which Shoe is Better? Shoe 1 Shoe 2 Shoe 3 Price: $180 Comfort: pretty good, a little stiff, not that cushiony Looks: multiple colors, fancy style, famous brand Function: medium weight, very durable, supportive Price: $45 Comfort: okay, loose fit, not much cushion Looks: classic, retro, many color choices, minimal styling, famous brand Function: medium weight, low durability, little support Price: $160 Comfort: very good, soft, warm Looks: simple, one color, minimal styling Function: light weight, not durable, little support How do we compute a rating (0 to 100) for each shoe?
Which Shoe is Better? Shoe 1 Shoe 2 Shoe 3 Price: $180 Comfort: pretty good, a little stiff, not that cushiony Looks: multiple colors, fancy style, famous brand Function: medium weight, very durable, supportive Price: $45 Comfort: okay, loose fit, not much cushion Looks: classic, retro, many color choices, minimal styling, famous brand Function: medium weight, low durability, little support Price: $160 Comfort: very good, soft, warm Looks: simple, one color, minimal styling Function: light weight, not durable, little support We need numbers!
We need to Quantify it! Shoe 1 Shoe 2 Shoe 3 Price: $180 Comfort: 6 Looks:8 Function: 8 Price: $45 Comfort: okay, loose fit, not much cushion Looks: classic, retro, many color choices, very minimal styling, famous brand Function: medium weight, low durability, not supportive Price: $160 Comfort: very good, soft, warm Looks: classic, retro, two colors, minimal styling, famous brand Function: light weight, kinda durable Rate the factors on a scale from 0-10. 0 = worst 10 = best
We need to Quantify it! Shoe 1 Shoe 2 Shoe 3 Price: $180 Comfort: 6 Looks: 8 Function: 8 Price: $50 Comfort: 5 Looks: 7 Function: 6 Price: $120 Comfort: 8 Looks: 7 Function: 6 But what about the price? It isn’t in the same units as the others.
We need to Quantify it! Shoe 1 Shoe 2 Shoe 3 Price: $180 (1) Comfort: 6 Looks: 8 Function: 8 Price: $50 Comfort: 5 Looks: 7 Function: 6 Price: $120 Comfort: 8 Looks: 7 Function: 6 We need to rate the price using the same scale (0 to 10) . 0 = Expensive, 10 = Inexpensive
Selection Ifprice <=20Then price =10 ElseIfprice <=40Then price =9 Etc…
Which Shoe is Better? Shoe 1 Shoe 2 Shoe 3 Do all the factors have the same importance? (We all know looks matters more than comfort, right?) Price: $180 Comfort: pretty good, a little stiff, not that cushiony Looks: multiple colors, fancy style, famous brand Function: medium weight, very durable, supportive Price: $45 Comfort: okay, loose fit, not much cushion Looks: classic, retro, many color choices, minimal styling, famous brand Function: medium weight, low durability, little support Price: $160 Comfort: very good, soft, warm Looks: simple, one color, minimal styling Function: light weight, not durable, little support
Priority • Put the four factors in order from most to least important. Price, Comfort, Looks, Function 1. _________________ (most important) 2. _________________ 3. _________________ 4. _________________ (least important)
Weighting the Priorities • You have a total of 10 weights to use. Allocate the weights based on priority. 1. Looks x 3 2. Price x 3 3. Comfort x 2 4. Function x 2 Adds up to 10 ____ 10
Equation to Rate a Shoe 0 to 10WeightTotal + + + Price: ____ Comfort: ____ Looks: ____ Function: ____ x ____ = ____ x ____ = ____ x ____ = ____ x ____ = ____ Rating: _________
Sample Calculation 0 to 10WeightTotal + + + Price: 9 Comfort: 6 Looks: 7 Function: 5 x 2 = 18 x 2 = 12 x 4 = 28 x 2 = 10 Rating: 68
Sequence TextWindow.WriteLine("Rate the price:") price=TextWindow.Read() VS. price=TextWindow.Read() TextWindow.WriteLine("Rate the price:")
Selection Ifrepeat="y"Then GotoStart EndIf Checks if the user types in “y”
Iteration Ifrepeat="y"Then GotoStart EndIf Checks if the user types in “y” Goes back to beginning and repeats program ‘top of program code Start: GraphicsWindow.Draw...
Exit Card • Write down the equation you used to rate a shoe. • Write example sets of inputs for two shoes and calculate the rating. • Describe the relationship between the input variables. • How does each affect the rating? • Compare one variable’s effect to another.