Sa4 1
Sa4 1
1. (35%) Draw a flowchart which will calculate the result based on the following operations:
Addition, Subtraction, Multiplication, Division and Modulo. The program shall calculate each row
of given numbers using loops.
Pseudo-code:
Start
Input N1 and N2
Output N1 + N2
Output N1 - N2
Output N1 * N2
Output N1/N2
Output N1%N2
If b=0, OUTPUT “Undefined”
End
FLOWCHART:
Start
Input N1 and N2
Output N1 + N2
Output N1 - N2
Output N1 * N2
Output N1 / N2
Output N1 % N2
End
NAME: Julliana T. Viloria CES 1102L
BSCE – 1 DATE:
2. (30%) Write an algorithm and draw a flowchart which will allow the user to enter values for
weight in pounds (lbs) and height in centimeters (cm). The program then output the body mass
index (BMI) in kg/m2 and classification of the BMI (see table below). Note: 1 lbs = 0.453592 kg
Pseudo-code:
Start
Enter “A person weight”; W(kg)
Enter “A person height”; H(m)
Divide W by H^2, where the results is the “BMI”
Let BMI<18.5
If yes, print “Underweight”
If no, don’t print “Underweight”
Let BMI>18.5 but BMI<22.9
If yes, print “normal range”
If no, don’t print “normal range”
Let BMI>25 but BMI<29.9
If yes, print “obese I”
If no, don’t print “obese I”
Let BMI>30
If yes, print “obese II”
If no, don’t print “obese II”
End
NAME: Julliana T. Viloria CES 1102L
BSCE – 1 DATE:
Flowchart:
Start
If yes, print “obese II” Let BMI>30 If no, don’t print “obese II”
End
NAME: Julliana T. Viloria CES 1102L
BSCE – 1 DATE:
3. (35%) Create a flowchart that shall determine the number of infants (0-2), children (3-12),
teenagers (13-17), adults (18 & above) in a group of people. The user shall input the number of
people to classify. Use loops in entering the age of the people. After all the ages are entered,
display the number of persons classified as infant, children, teenagers and adults.
Pseudo-code:
START
INPUT age of a person (AP)
INITIALIZE Count (C), C=0
While C<15
GET number of infants (I), when AP>0 but AP<2
GET number of children’s (CH), when AP>3 but AP<12
GET number of teenagers (T), when AP>13 but AP<17
GET number of adults (A), when AP>18
DISPLAY number of infants (I)
DISPLAY number of children’s (CH)
DISPLAY number of teenagers (T)
DISPLAY number of adults (A)
OUTPUT
END
Start
FLOWCHART:
End