Answered step by step
Verified Expert Solution
Link Copied!

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 5.26$, customer gives 6$, then the algorithm should tell the vendor to give back 0.74$ to the customer.
After you finish your coding, you should simulate all three possible scenarios and show the outputs one by one:
1)Customer gives less money than the purchase amount. In this case, give a warning like "The money is not enough".
2)Customer gives exact money as the purchase amount. In this case, the output will be 0(zero).
3)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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions