Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Design an algorithm and a code to simulate a money exchange between the costumer and the vendor. Every time customer gives a money, algortihm should
Design an algorithm and a code to simulate a money exchange between the costumer and the vendor. Every time customer gives a money, algortihm should calculate how much money should be given back as the change. The purchase amount and the customer money should be given at the beginning. The algorithm should give the coin amounts. Example: Purchase is $ customer gives $ then the algorithm should tell the vendor to give back $ to the customer.
After you finish your coding, you should simulate all three possible scenarios and show the outputs one by one:
Customer gives less money than the purchase amount. In this case, give a warning like "The money is not enough".
Customer gives exact money as the purchase amount. In this case, the output will be zero
Customer gives more money than the purchase amount. In this case, the output will be the change amount as in the example above
For this question, identify the inputs and outputs for the code. Identify the mathematical expression for the problem. Finally put all in MATLAB language.
Identify what are the different possible scenarios and how to code those.
You don't have to report your algorithm you will submit only your Matlab code.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started