CS WK 7
CS WK 7
Introduction
Step-by-Step Algorithm
1. Initialization
2. User Input
1. Initialize variable_expenses to 0.
2. Create a loop to collect multiple variable
expenses:
- While true:
- Prompt the user to enter a variable
expense or type "done" to finish.
- If the user types "done", break the loop.
- Otherwise, convert the input to a float and
add it to variable_expenses.
4. Budget Calculation
1. If remaining_budget > 0:
- Print "You have a surplus of
[remaining_budget] this month."
2. Else if remaining_budget < 0:
- Print "You have a deficit of
[remaining_budget] this month."
3. Else:
- Print "You have broken even this month."
6. Output Results
Finally, we will display the results:
Debugging Techniques
1. Print Statements
Example:
print("Fixed Expenses:", fixed_expenses)
print("Variable Expenses:", variable_expenses)
print("Calculated Remaining Budget:",
remaining_budget)
2. Unit Testing
3. Boundary Testing
4. Code Review
5. Debugging Tools
Conclusion