0% found this document useful (0 votes)
147 views2 pages

Rodriguez Hw2

The document contains two algorithms for calculating student grades and salesperson earnings. The first algorithm uses an if-else statement to calculate a student's final grade based on their exam, quiz, and attendance scores, adding a bonus of 10 or 2 points depending on attendance. The second algorithm uses an if-else statement to calculate a salesperson's total earnings, which is their $3,500 basic salary plus a 10% commission if their gross sales meet the $10,000 quota. Sample inputs and outputs are provided to demonstrate each algorithm.

Uploaded by

Kent Rodriguez
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)
147 views2 pages

Rodriguez Hw2

The document contains two algorithms for calculating student grades and salesperson earnings. The first algorithm uses an if-else statement to calculate a student's final grade based on their exam, quiz, and attendance scores, adding a bonus of 10 or 2 points depending on attendance. The second algorithm uses an if-else statement to calculate a salesperson's total earnings, which is their $3,500 basic salary plus a 10% commission if their gross sales meet the $10,000 quota. Sample inputs and outputs are provided to demonstrate each algorithm.

Uploaded by

Kent Rodriguez
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/ 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

You might also like