Sample Algorithm - Solutions
Dear Students,
I am providing some sample algorithms below for three exercises from the back of Chapter 1 in the textbook. My intention in providing these algorithms is to assist you in completing the Week 3 assignments.
Q. 17 on Page# 25
Step 1: Display a prompt for user to enter Radius
Step 2: Accept the Radius input from the user
Step 3: Display a prompt for user to enter Price
Step 4: Accept the Price input from the user
Step 5: Calculate and store the area of the Pie using this formula
Area = Pi * radius * radius
Where Pi = 3.142
Step 6: Calculate and store the Price per square inches
Step 7: Display a prompt for Price per square inches
Step 8: Display the value for Price per square inches
Q. 20 on Page# 25
Step 1: Display a prompt for user to enter the “Square yards of Mowing”
Step 2: Accept the input for “Square yards of Mowing” from user
Step 3: Display a prompt for user to enter the “Number of fertilizing applications”
Step 4: Accept the input for “Number of fertilizing applications”
Step 5: Display a prompt for user to enter the “Number of Trees to plant”
Step 6: Accept the input for “Number of Trees to plant”
Step 7: Calculate and store the cost of Mowing using “$30 per square yards” as the standard rate
Step 8: Calculate and store the cost of Fertilizing using “$30 per application” as the standard rate
Step 9: Calculate and store the cost of Planting trees using “$50 per tree” as the standard rate
Step 10: Calculate and store the overall total
Step 11: Display a prompt for the Overall Total
Step 12: Display the value of Overall Total to the user
Q. 24 on Page# 26
Step 1: Store “Total cost per semester”
Step 2: Store “Total units per semester”
Step 3: Calculate and store the per unit cost by dividing “Total cost” by “Total units”
Step 4: Calculate and store cost for math class by multiplying per unit cost by 4
Step 5: Calculate and store per week cost of math class by dividing the outcome from step 4 by 15
Step 6: Calculate and store per session cost of math class by dividing the outcome from step 5 by 3
Let me know if I can do anything else to assist you.
Thanks,
Ashish