PP3 - Seat Work Exercises - Flowchart -Conditional
1. Given two numbers X and Y. Draw a flowchart to determine the difference between X
and Y. If X-Y is negative, compute R=X+Y, if X-Y is zero, compute R=2X+XY; and if
X-Y is positive, compute R=X*Y. Print out the values of X, Y, and R.
Algorithms:
Step 1: Read in the values of X and Y
Step 2: Subtract Y from X
Step 3: If the difference between X-Y is negative. Computer R=X+Y, if zero, compute
R=2x+XY; and if X-Y is Positive, Compute R=X*Y.
Step 4: Print out the values of X, Y and R
Flowchart:
START
A
READ X, R=X+Y
If R=X*Y
Y
Diff
B
Diff=X, Y Print X,
Y, R B
R=2X+2
Y
A END
B
2. The ABC Manufacturing Company plans to give a year-end bonus to each of its
employees. Make a flowchart that will input the name and the salary then compute the
bonus of an employee. Consider the following criteria: If the employee’s monthly salary
is less than 1,000.00 pesos, the bonus is 50% of the salary; for the employees with
salaries greater than 1,000.00 pesos, the bonus is 1,000.00. Print out the name and
corresponding bonus of the employee.
Algorithms:
Step1: Read in the employee’s name and salary
Step2: Test if the employee’s salary is less than 1,000,00
Step3: If the salary is less than 1,000,00 pesos, the bonus is 50% of the employee’s salary.
However, if the salary is more than 1,000.00 pesos the bonus is 1,000,00 pesos.
Step4: Print out the employee’s name and bonus
Flowchart:
START A
Read Bonus=5 Y Is N Bonus
Name,
- Salary Salary =1000
Salary
<1000
B
Print B
A Name.
Bonus
END