Vous êtes sur la page 1sur 9

# De La Salle University

LBYCPA1

Labaratory Activity #2
FINAL REPORT

## Contreras, Teofilo Jr. M.

EQ3/ M 7:30am - 10:30am 11:00 am – 2:00 pm

## Tiu, Emerson Karl M.

EQ3/ M 7:30am - 10:30am 11:00 am – 2:00 pm

Rating: _______

Instructor
I. Problem
1. Write a C program that will ask the user to enter the lengths of a femur bone and a
humerus bone from the same person. The program will compute the heights for
both males and females from each bone.
2. Modify the program in problem 1 so that it asks the user to enter the values in
feet.
II. Solution
A. Algorithm
1.
Step 1:
Start
Step 2:
Declare Variables for femur_length and humerus_length.
Step 3:
For femur_length, calculate female height by multiplying femur_length with 1.94
then add 28.7 and calculate male height by multiplying femur_length with 1.88
For humerus_length, calculate female height by multiplying humerus_length
with 2.8 then add 28.2 and calculate male height by multiplying humerus_length
Step 4:
Display female and male height calculated from femur_length. Add unit “in” for
each result.
Display female and male height calculated from humerus_length. Add unit “in”
for each result.
Step 5: Stop
2.
Step 1:
Start
Step 2:
Declare variables for femur_length and humerus_length in terms of feet.
Step 3:
Convert femur_length and humerus_length in inches by multiplying them by 12.
Step 4:
For femur_length, calculate female height by multiplying femur_length with 1.94
then add 28.7 and calculate male height by multiplying femur_length with 1.88
For humerus_length, calculate female height by multiplying humerus_length
with 2.8 then add 28.2 and calculate male height by multiplying humerus_length
Step 5:
Convert femur_length and humerus_length back in feet by dividing them by 12.

Step 6:
Display female and male height calculated from femur_length. Add unit “in” for
each result.
Display female and male height calculated from humerus_length. Add unit “in”
for each result.
Step 7:
Stop
B. Flowchart
1.

2.
C. Source Code
1.
femur_length = float(input('Enter your Femur Length(in):'))
humerus_length = float(input('Enter your Humerus Length(in):'))

## fl_female_height = femur_length * 1.94 + 28.7

fl_male_height = femur_length * 1.88 + 32

## hl_female_height = humerus_length * 2.8 + 28.2

hl_male_height = humerus_length * 2.9 + 27.9

## print('Height Estimation from femur length:')

print('female height =', '%.1f'%fl_female_height, 'in')
print('male height =', fl_male_height, 'in')
print('')
print('Height Estimation from humerus length:')
print('female height =', hl_female_height, 'in')
print('male height =', '%.1f' %hl_male_height, 'in')

2.
femur_length = float(input('Enter your Femur Length(ft):'))
humerus_length = float(input('Enter your Humerus Length(ft):'))

femur_length = femur_length * 12
humerus_length = humerus_length * 12

## fl_female_height = femur_length * 1.94 + 28.7

fl_male_height = femur_length * 1.88 + 32

## hl_female_height = humerus_length * 2.8 + 28.2

hl_male_height = humerus_length * 2.9 + 27.9

fl_female_height = fl_female_height / 12
fl_male_height = fl_male_height / 12
hl_female_height = hl_female_height / 12
hl_male_height = hl_male_height / 12

## print('Height Estimation from femur length:')

print('female height =', '%.1f'%fl_female_height, 'ft')
print('male height =', '%.1f'%fl_male_height, 'ft')
print('')
print('Height Estimation from humerus length:')
print('female height =', '%.1f'%hl_female_height, 'ft')
print('male height =', '%.1f' %hl_male_height, 'ft')

III. Output
1.
2.

IV. Discussion
For the first part of the problem, we need to ask the value of the length of femur
and humerus length to the user. We can do it by using input() and inside the
parentheses we can put the message we want to show on the screen like “Enter value
here:”. We added a code float() to avoid error when the user type a number that
contains decimal. Then we stated the formula to compute the estimated height. We
wrote in a syntax that can be understand by the computer when using Python like this:

Now, we showed the results on the screen by using the code print() including the
variables that contains the height and a code '%.1f'% before the variable to indicate a
one decimal place only.
The second part of the problem is very similar to the first part but we need to add
some procedure. We the value of the length of femur and humerus length to the user
in terms of feet. Since the formula for the height estimation uses inches we converted
the length from feet to inches by mulpying it with 12. We can now use the formula
given for the height estimation just like we did on the first problem. The height we
get in this formula is in terms of inches and we converted it back to feet by dividing it
to 12. Now, we showed the results on the screen by using the same format but we
replaced “in” into “ft”.

V. Conclusion
In this activity, I learned how to analyze a problem and solve it. Reading
the problem at first seems like a difficult one but it isn’t if you think properly.
First, I define the desired output which is the height of a male and female
estimated with femur and humerus length. Then I consider what process to do to
achieve it. So I put the formula given. At first run of the program, there some
errors I encounter like wrong spellings and what code I must add to make it
correct. Programming really challenges you to think of different ways to solve a
problem.

VI. References

https://www.edmodo.com/file/view-office-online?fid=893504076

https://www.programiz.com/article/algorithm/algorithm-programming

https://www.draw.io/