Professional Documents
Culture Documents
CSC 121 Ass 1
CSC 121 Ass 1
CSC 121 Ass 1
START
Question 2
Algorithm
Input INCOME(I),
START
RENT(R)
Step 1: input homework_scores, test_scores.
Calculate
Step 2: Iterate Percentage:
over the homework(RENT/INCOME)
scores and use the*min
100 function to find the
lowest score. If this score is lower than min_homework, update
homework_scores to this score.
Step 3: Iterate over the test scores
Print and use the min function to find the lowest
Percentage
score. If this score is lower than min_test, update test_scores to this score.
Step 4: Sum up the remaining homework and test scores (i.e. all scores except
the lowest homework and test scores).
STOP
Step 5: Add these scores together to get the total points earned.
Step 6: Calculate the percentage of the total points earned by dividing the total
points earned by the total possible points.
Step 7: Return the final points as a percentage.
STOP
Psuedo Code
calculateFinalPoints(homework_scores, test_scores):
min_homework = max(homework_scores)
min_test = max(test_scores)
for score in homework_scores:
if score < min_homework:
min_homework = score
for score in test_scores:
if score < min_test:
min_test = score
total_points = sum(homework_scores) + sum(test_scores) - min_homework - min_test
total_possible_points = (len(homework_scores) - 1) * max(homework_scores) + (len(test_scores) - 1) *
max(test_scores)
final_points = total_points / total_possible_points * 100
return final_points
Question 3
Pseudo Code
1. Begin
2. Input name, mark
3. new_mark = mark+5
4. Print name, new_mark
5. End
Flowchart
Start
Input name,
hours_worked,
wage_per_hour
Print name,
net_pay
End