You are on page 1of 16

Week 003

Problem Solving through


Flowcharts 2
Week 003: Problem Solving through Flowcharts 2

Problem Solving

Question: Write a program that accepts an integer input


from the user and display the least number of combinations
of 10s, 5s, and 1s.
Week 003: Problem Solving through Flowcharts 2

Problem Solving

We start of by using START terminator.


Week 003: Problem Solving through Flowcharts 2

Problem Solving

Next we used the Preparation symbol to


declare our variables. We will be needing
three (3) variables for our computations.

The userValue variable will contain the


number entered by the user.
Week 003: Problem Solving through Flowcharts 2

Problem Solving

The remainingValue variable will contain


the remaining values after they complete
the necessary computations.

The temp variable will contain the result


of the computations. This variable will
also be used to display the result to the
user per combination.
Week 003: Problem Solving through Flowcharts 2

Problem Solving

Next we start our processing by


accepting an input by using the INPUT
Data symbol. We store the input to the
userValue variable.
Week 003: Problem Solving through Flowcharts 2

Problem Solving

Next we initialize our remaining value


variable with the value stored in the
userValue.

We do this to preserve the input from the


user.
Week 003: Problem Solving through Flowcharts 2

Problem Solving

Next we check if the


remaining value is greater
than or equal to the largest
denomination,10.

We do this because we do
not need to display that we
do not have 10
denominations.
Week 003: Problem Solving through Flowcharts 2

Problem Solving

Now we get the number of


10’s in our remaining value
by dividing the
remaningValue variable by
10.

We store the quotient to the


temp variable.
Week 003: Problem Solving through Flowcharts 2

Problem Solving

Since we now know the


number of 10’s in the
remainingValue variable,
we need to determine the
remainder by subtracting
the remaining value and the
quotient, temp.

We store the
remainder/difference to our
remainingValue variable.
Week 003: Problem Solving through Flowcharts 2

Problem Solving

We display the quotient as


a concatenation of the
string “There are “ … “ 10’s”
through the variable temp.
Week 003: Problem Solving through Flowcharts 2

Problem Solving

Next we check if the


remaining value is greater
than or equal to the largest
denomination,5.

We do this because we do
not need to display that we
do not have 5
denominations.
Week 003: Problem Solving through Flowcharts 2

Problem Solving

Now we get the number of


5’s in our remaining value
by dividing the
remaningValue variable by
5.

We store the quotient to the


temp variable.
Week 003: Problem Solving through Flowcharts 2

Problem Solving

Since we now know the


number of 5’s in the
remainingValue variable,
we need to determine the
remainder by subtracting
the remaining value and the
quotient, temp.

We store the
remainder/difference to our
remainingValue variable.
Week 003: Problem Solving through Flowcharts 2

Problem Solving

We display the quotient as


a concatenation of the
string “There are “ … “ 5’s”
through the variable temp.
Week 003: Problem Solving through Flowcharts 2

Problem Solving

We will display the number


of 1’s we have through the
variable temp.

And lastly we will end our


computation using the END
terminator.

You might also like