This assignment for Application Development ( Visual Basic Studio) Write out the
ID: 3664369 • Letter: T
Question
This assignment for Application Development ( Visual Basic Studio)
Write out the pseudocode to solve a problem of making change for a customer in the fewest units possible (pennies, nickels, dimes, quarters, $1, $5, $10 bills.)
The pseudocode represents plain English statements of how to solve a particular problem (the algorithm.) This means that you do not write VB code at all, just plain, high-level English statements.
There are multiple ways to solve this problem, not just a single method. You can use math, loops, anything in your pseudocode to solve this. At the end, you should be able to use any amount due and amount given and go through your algorithm and get the correct amount of change to give back.
As an example:
The customer owes $2.79 but gives you a $5. Write the steps to calculate how many of each denomination of currency needs to be given back as change. What if the customer gave you $10, what about $3. The steps you write should be generic enough to calculate change for any given amounts.
This assignment is to help you with problem solving, as such, you are to work on this alone and submit your own work. This is about working towards learning the process of problem solving and writing algorithms.
Due as a text document (Word) in Blackboard.
Explanation / Answer
I can't show output since this is only an algorithm
read bill amount from user into $bill_amount
read payment amount from user into $payment
if $payment < $bill_amount
tell user that payment is insufficient
else
set $balance to ($payment - $bill_amount)
// now integer part of balance represents number of dollars
// and decimal part represents number of cents to be given back
set $dollars to integer part of $balance
set $cents to decimal part of $balance * 100
if $dollars >= 10
number of $10 bills = quotient of $dollars/10
// remove $10 bills paid from dollars
$dollars = remainder of $dollars/10
end if
if $dollars >= 5
number of $5 bills = quotient of $dollars/5
// remove $5 bills paid from dollars
$dollars = remainder of $dollars/5
end if
if $dollars >= 1
number of $1 bills = $dollars
// balance is less than a dollar now
$dollars = 0
end if
if $cents >= 25
number of quarters = quotient of $cents/25
// remove quarters paid from cents
$cents = remainder of $cents/25
end if
if $cents >= 10
number of dimes = quotient of $cents/10
// remove dimes paid from cents
$cents = remainder of $cents/10
end if
if $cents >= 5
number of nickels = quotient of $cents/5
// remove nickels paid from cents
$cents = remainder of $cents/5
end if
if $cents >= 1
number of pennies = $cents
// we paid the complete balance to customer
$cents = 0
end if
enf if