Introduction Don’t even think about opening up Visual Studio on Programming Assi
ID: 3605739 • Letter: I
Question
Introduction
Don’t even think about opening up Visual Studio on Programming Assignment 5! Good news, it is not another Mathinator! Although we all agreed that C# is cool, this lab assignment is not about C#.
As you’ve tackled recent programming assignments, did you have that moment when you weren’t really sure where to start? What did you do? Did you fire up Visual Studio and start writing code? Be honest. You know you did it… You know who you are…
Chapter 5 introduces us to pseudocode. As we discussed in class, pseudocode is a great tool for developing an algorithm. Good pseudocode skills allow us to iteratively visualize an algorithm and decompose our programming challenges.
Assignment & Discussion
Your task in Programming Assignment 5 is to pseudocode my caffeine habit. It’s not uncommon for me to purchase a Diet Coke from time to time. Not uncommon at all. My favorite Coke machine in Allgood Hall has Diet Cokes in selections B1 through B5. I always select B1. I don’t always get a Diet Coke from B1. Why is that? As we discussed, there’s an algorithm coded into this machine that will select a Diet Coke for me and keep the B1 – B5 slots as even as possible; i.e. it won’t necessarily dispense a Diet Coke from B1 when I select B1. It’s likely a marketing goal to keep the front role filled.
Develop pseudocode that could be implemented in a Coke machine that will accomplish what I described above. The overall goal is to keep the B1 – B5 slots as even as possible and not to allow an empty slot until absolutely necessary.
Limit your pseudocode to Diet Cokes in slots B1 – B5. You are to pseudocode the entire transaction, to include: entering money to cover $1.25 cost, making a selection, determining which slot to dispense the product from, dispensing the product, determining if change is due, calculating how much change to dispense, and dispensing change. Assume that your algorithm, once implemented, will reset each time the machine is restocked. In other words, start your pseudocode effort with a full machine. Your pseudocode should be of sufficient detail to allow for a complete picture of my Diet Coke purchase.
Requirements
Do not open Visual Studio, do not submit C# code.
Submit your pseudocode in a Microsoft Word document, named “CSCI 1301CD Programming Assignment 5 - LastName”. There will be a 5% penalty for not naming your file correctly.
Ensure your name, section (CSCI 1301CD) and date are at the top of your pseudocode.
Follow the Chapter 5 and lecture guidance for creating pseudocode
Explanation / Answer
if user inputs a legal coin C (e.g. 5, 10, or 25):
coins[C] = coins[C]+1
Bal = Bal+C
if user presses the 'return change' button:
make_change(Bal)
Bal = 0
if user presses button for can of type X:
if available[X]=False:
print("unavailable, make another choice")
else if Bal<cost(X):
print("insufficient funds, put in more money")
else:
dispense(X) // machine will update available[X]
make_change( Bal-cost(X))
Bal = 0
subroutine make_change(Bal):
while Bal>0:
if Bal>25 and coins[25]>0:
dispense quarter
coins[25] = coins[25]-1
Bal = Bal-25
else if Bal>10 and coins[10]>0:
dispense dime
coins[10] = coins[10]-1
Bal = Bal-10
else if Bal>5 and coins[5]>0:
dispense nickel
coins[5] = coins[5]-1
Bal = Bal-5
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.