Welcome to Beginners Programming.
Draw a flowchart that would input the name, age and gender of a person, print “Hello” if age is less than or equal to 59, else “Hi”, and print also the name.
Flowchart:
Our lesson now is to analyze the word problem. Firstly, we must determine what the problem wants, what the given values are, what are we looking for, what is the formula (for computations if any), and what it want to display. Let’s try an example problem.
Problem 1:
Given the radius of 8.4, compute for the area of the circle, and print out the radius and the area of the circle on the screen.
What does the problem want?
1. compute for the area of the circle
2. display the radius and area to the screen
What is given?
1. radius=8.4
2. PI = 3.1416 (constant)
How to we compute for the area of the circle?
Formula: PI * radius2
PI = 3.1416
What are the variables needed?
1. PI
2. radius
3. area
Now with this information what we have, we can now draw a flowchart out of it.
And there you have it.
Problem 2:
Draw a flowchart that would input three (3) numbers, compute for the sum, average and product. Display the sum, average and product on the screen.
What does the problem want?
1. Compute for the sum of the 3 numbers
2. Compute for the average of the 3 numbers
3. Compute for the product of the 3 numbers
4. Display the sum, average and product on the screen.
What is given?
1. None
Where do we get the values of the three numbers?
1. By input (from the user)
What are the formulas needed
1. sum = x1 + x2 + x3
2. average = sum / 3
3. product = x1 * x2 * x3
What are the variables needed?
1. Sum
2. Average
3. Product
4. N1, N2, N3 (for the 3 numbers)
Now we are ready to draw a flowchart. (You can use a pencil and paper)
Are we feeling the flow now? I hope you do, because it will be your ammunition to creating an actual computer program, well at least it will be your basis and guide, an overview as to how your program will flow. We will try a flowchart with a decision.
Problem 3:
The XYZ Manufacturing Inc., is giving each employee a year end bonus. If the employee salary is <>= 1000, the bonus is 1000. Draw a flowchart that would compute for the employee’s bonus and display the employee total salary.
By this time I assume that you already understood how to understand the word problem, define the variables to be used, and the flowchart making techniques. I am trying my best to make it as easy as possible for you. And if you do have questions and or comments, it is very much welcome.
Next lesson would be a more complex flowchart.
-End of lesson 5 Beginners Programming
No comments:
Post a Comment