Uploaded by Huqawida

Lab 20 Solution part1

advertisement
Part I
Exercise 1 - TotalCost
Main Program Memory
calculate_total_cost Function Memory
discount
Step no
I/O
ticket_price
number_of_attendees
total_cost
attendees
ticket_price
discount_rate
total_cost
50
10
11
50
8
50
8
50
8
8
50
50
8
8
50
Enter the number of attendees: 8
12
1
2
0
50
8
8
50
3
0
50
8
8
50
8
8
50
4
0.1
50
0.1
7
400
50
8
8
50
0.1
8
50
8
8
9
50
0.1
40.0
400
50
8
12
360.0
50
13
40.0
400
Total cost for 8 attendees: $360.0
8
360.0
Part I
Exercise 2 - BMICalculator
update_bmi Function Memory
Main Program Memory
Step
no
I/O
height
weight
final_bmi
total_changes
height
weight
bmi
changes
1
Enter your height: 1.75
1.75
2
Enter your weight: 75
1.75
75
11
1.75
75
13
1.75
75
14
1.73
75
15
1.73
75
3
1.73
75
1.73
75
4
1.73
75
1.73
75
25.05930703
5
1.73
75
1.73
75
25.05930703
0
6
1.73
75
1.73
75
25.05930703
0
7
1.73
75
1.73
74
25.05930703
0
8
1.73
75
1.73
74
24.72518293
0
9
1.73
75
1.73
74
24.72518293
1
6
1.73
75
1.73
74
24.72518293
1
10
1.73
75
1.73
74
24.72518293
1
15
1.73
75
24.72518293 1
16
Final BMI: 24.73
1.73
75
24.72518293 1
17
Total Changes: 1
1.73
75
24.72518293 1
Download