Upload
devonte-ritson
View
214
Download
0
Tags:
Embed Size (px)
Citation preview
Rating a Shoe
Objectives:1. Explain how sequence, selection, and
iteration are building blocks of algorithms2. Create equations with two or more
variables to represent relationships among quantities.
Warm-Up
R = 3L + 3P + 2C + 2F1. Solve for R given the following variable values:
a) L = 7 P = 4 C = 8 F = 6b) L = 9 P = 8 C = 7 F = 4
2. Describe the relationship between variables L, P, C, & F.c) Do they all affect R equally?d) How does L affect R? e) How does L’s effect on R compare to P’s? f) How does L’s effect on R compare to C’s?
Which Shoe is Better?
Shoe 1
Price: $180Comfort: pretty good, a little stiff, not that cushionyLooks: multiple colors, fancy style, famous brandFunction: medium weight, very durable, supportive
Shoe 2
Price: $45Comfort: okay, loose fit, not much cushionLooks: classic, retro, many color choices, minimal styling, famous brand
Function: medium weight, low durability, little support
Shoe 3
Price: $160Comfort: very good, soft, warm Looks: simple, one color, minimal stylingFunction: light weight, not durable, little support
Computing a Problem
1. Identify Factors: Variables
2. Quantify: Numbers & Units
3. Express the Relationship: Equation
4. Algorithm: How my mind does it
5. Coded Algorithm: How computer does it
Which Shoe is Better?
Shoe 1
Price: $180Comfort: pretty good, a little stiff, not that cushionyLooks: multiple colors, fancy style, famous brandFunction: medium weight, very durable, supportive
Shoe 2
Price: $45Comfort: okay, loose fit, not much cushionLooks: classic, retro, many color choices, minimal styling, famous brand
Function: medium weight, low durability, little support
Shoe 3
Price: $160Comfort: very good, soft, warm Looks: simple, one color, minimal stylingFunction: light weight, not durable, little support
How do we compute a rating (0 to 100) for
each shoe?
Which Shoe is Better?
Shoe 1
Price: $180Comfort: pretty good, a little stiff, not that cushionyLooks: multiple colors, fancy style, famous brandFunction: medium weight, very durable, supportive
Shoe 2
Price: $45Comfort: okay, loose fit, not much cushionLooks: classic, retro, many color choices, minimal styling, famous brand
Function: medium weight, low durability, little support
Shoe 3
Price: $160Comfort: very good, soft, warm Looks: simple, one color, minimal stylingFunction: light weight, not durable, little support
We need numbers!
We need to Quantify it!
Shoe 1
Price: $180Comfort: 6Looks: 8Function: 8
Shoe 2
Price: $45Comfort: okay, loose fit, not much cushionLooks: classic, retro, many color choices, very minimal styling, famous brand
Function: medium weight, low durability, not supportive
Shoe 3
Price: $160Comfort: very good, soft, warm Looks: classic, retro, two colors, minimal styling, famous brandFunction: light weight, kinda durable
Rate the factors on a scale from 0-10.
0 = worst 10 = best
We need to Quantify it!
Shoe 1
Price: $180Comfort: 6Looks: 8Function: 8
Shoe 2
Price: $50Comfort: 5Looks: 7
Function: 6
Shoe 3
Price: $120Comfort: 8Looks: 7Function: 6
But what about the price? It isn’t in the same units as
the others.
We need to Quantify it!
Shoe 1
Price: $180 (1)Comfort: 6Looks: 8Function: 8
Shoe 2
Price: $50Comfort: 5Looks: 7
Function: 6
Shoe 3
Price: $120Comfort: 8Looks: 7Function: 6
We need to rate the price using the same scale (0 to 10) .
0 = Expensive, 10 = Inexpensive
Which Shoe is Better?
Shoe 1
Price: $180Comfort: pretty good, a little stiff, not that cushiony
Looks: multiple colors, fancy style, famous brand
Function: medium weight, very durable, supportive
Shoe 2
Price: $45Comfort: okay, loose fit, not much cushionLooks: classic, retro, many color choices, minimal styling, famous brand
Function: medium weight, low durability, little support
Shoe 3
Price: $160Comfort: very good, soft, warm Looks: simple, one color, minimal stylingFunction: light weight, not durable, little support
Do all the factors have the same importance?(We all know looks matters more than comfort, right?)
Priority
• Put the four factors in order from most to least important.
Price, Comfort, Looks, Function1. _________________ (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 33. Comfort x 24. Function x 2
Adds up to 10
____10
Equation to Rate a Shoe
Price: ____
Comfort: ____
Looks: ____
Function: ____
x ____ = ____
x ____ = ____
x ____ = ____
x ____ = ____
+
+
+
Rating: _________
0 to 10 Weight Total
Sample Calculation
Price: 9
Comfort: 6
Looks: 7
Function: 5
x 2 = 18
x 2 = 12
x 4 = 28
x 2 = 10
+
+
+
Rating: 68
0 to 10 Weight Total
Sequence
TextWindow.WriteLine("Rate the price:")price = TextWindow.Read()
VS.
price = TextWindow.Read()TextWindow.WriteLine("Rate the price:")
Iteration
If repeat = "y" Then Goto StartEndIf Checks if the user
types in “y”Goes back to beginning and
repeats program
‘top of program codeStart: GraphicsWindow.Draw...