CSC 121 Ass 1

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

Name: Johnson-Oru Marvellous

Matric No: 22CG031872


Course: Computer Science
Course Code: CSC 121
Question 1
 Algorithm
Start
Step 1: Input the INCOME and RENT
Step 2: Calculate the percentage of the rent from the income by dividing the
RENT by the INCOME and multiplying the result by 100
Step 3: Output Percentage
Stop
 Pseudo Code
START
Input INCOME(I), RENT(R)
Calculate Percentage: (RENT/INCOME) * 100
Print Percentage
STOP
 Flow Chart

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

grosspay = hours_worked * wage_per_hour


tax = (10/100) * grosspay
net_pay = grosspay - tax

Print name,
net_pay

End

You might also like