[go: up one dir, main page]

0% found this document useful (0 votes)
20 views1 page

Worksheet Two

The document contains 10 problems asking to write algorithms to perform various tasks such as calculating interest, checking if a number is even or odd, displaying integers in ascending or descending order, calculating bonuses and salaries, guessing a random number, converting scores to letter grades, calculating incomes from different customer types, finding maximum and minimum values, calculating factorials, and determining if a year is a leap year.

Uploaded by

gediondaniel03
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views1 page

Worksheet Two

The document contains 10 problems asking to write algorithms to perform various tasks such as calculating interest, checking if a number is even or odd, displaying integers in ascending or descending order, calculating bonuses and salaries, guessing a random number, converting scores to letter grades, calculating incomes from different customer types, finding maximum and minimum values, calculating factorials, and determining if a year is a leap year.

Uploaded by

gediondaniel03
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Worksheet Three

Use both pseudo-code and flowchart for questions 1 -5


1. Write an algorithm that calculates the monthly interest earned by an account given its
balance and its annual interest rate.
2. Write an algorithm that checks whether a number is even or odd.
3. Given that n is provided by a user display the first n positive integers in
A) ascending order
B) descending order
4. It has been decided that a bonus of 12% of gross salary is to be given for each employee in
an organization. It was also agreed that if an employee has worked for more than 13 years
she/he is to receive an additional amount of Birr 350. Write an algorithm that calculates and
displays the bonus and the net salary.
5. Write an algorithm that chooses a random number between 1 and 20 and allow the user to
guess the number. The user is allowed only five trials. The algorithm should display guess
result (success or failure) and the number of trials. Assume generating a random number as a
step that can be performed by the machine executing the algorithm.
6. Write an algorithm that converts a score for a course to its corresponding letter grade using
the following scale. Your algorithm handles invalid input value.

Score Letter Grade Score Letter Grade


>=90 A+ >=55 C+
>=80 A >=45 C
>=75 B+ >=30 D
>=60 B otherwise F
7. The finance officers of the company XYZ want to calculate total income collected from a
number of customers. Every customer is registered as typeA, typeB or typeC customer.
TypeA, typeB and typeC customers pay 100, 200, and 300 birr each respectively. Write an
algorithm that gets the customer type and calculates the subtotal income for each type and
the total income collected by the finance officer from all his customers. Invalid type entry
must be anticipated and properly handled.
8. A set of integers is to be entered by the user one by one. A negative or zero entry marks the
end of entry. Search and display the maximum and minimum of the list of numbers.
9. Calculate and display the factorial of a number n.
10. Write an algorithm that determines whether a given year is leap year or not.

You might also like