Sie sind auf Seite 1von 2

RODRIGUEZ, Gervin Kent O.

11506816

MMINTER2

Homework # 2

1. A researcher computes for the grade of his students using the formula: grade = exam * 40%
+ quiz * 40% + attendance * 20%. If the student incurred no absence (attendance is 100), a
bonus of 10 is added to the grade, otherwise only 2 points is added. Design an algorithm using
a selection structure for program that will obtain the students data and display the
corresponding grade.



INPUT:
exam grade,quizgrade, attendance

PROCESS:
exam grade * 0.4, quiz grade * 0.4,
attendance * 0.4
attendance =/= 100 + 10, >100 =
+ 2
final grade = exam grade + quiz
grade + attendance


OUTPUT: final grade


Start

Set finGrd = 0; exmGrd = 0;
qzGrd = 0; attGrd = 0

Input exmGrd

Read exmGrd

Input qzGrd

Read qzGrd

Input attGrd

IF (attGrd == 100)

THEN finGrd = ((exmGrd *
0.4) + (qzGrd * 0.4) +
attGrd * 0.2)) + 10

ELSE

THEN finGrd = ((exmGrd *
0.4) + (qzGrd * 0.4) +

attGrd * 0.2)) + 2

Display finGrd

END IF

Stop



SIMULATION:



Enter exam grade: 80

Enter quize grade: 85



Enter attendance grade: 90



Final grade: 86
2. One large chemical company pays its salespersons on a commission basis.
The salespersons receive basic salary of P3500 per week plus 10 percent of their gross sales
for that week if the sales quota of P10,000 has been met. Otherwise, the salespersons only
receive the basic salary.

For example, a salesperson who sells P10,000 worth of chemicals in a week receives P3500
plus 10 percent of P10,000, or a total of P4500.

Design a algorithm using a selection structure for program that will obtain salespersons gross
sales. The program then will calculate and display the salespersons total earnings.

INPUT:
grossSale, salary, quota

PROCESS:
grossSale >= quota, salary +
(0.1*grossSale),

grossSale < quota, salary



OUTPUT:
total earnings

Start

Set grossSale = 0; salary =


3500.00;
quota = 10000.00;
totalEarn = 0

Input grossSale
Read grossSale

IF (grossSale >= quota)

THEN totalEarn = salary +


(0.1*grossSale)
Display totalEarn
ELSE


SIMULATION:

Enter sales: 5000


Total earnings: 3500.00

Enter sales: 10000

Total earnings: 4500.00

Das könnte Ihnen auch gefallen