Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a code that would work as a self-checkout machine system. For example, the

ID: 3850614 • Letter: W

Question

Write a code that would work as a self-checkout machine system. For example, the consumer inserts a $20 note for a purchase of $2.37, then the code should calculate the difference and return it in the very minimum number of notes and coins possible, as follows: $100 - $72.37 = $27.63 $20(1), $5(1), $1(2), $0.25(2), $0.10(1), $0.01(3) Your code should ask first for the balance, then the money deposited, and finally it should calculate the difference and the change returned. USING MATLAB LANGUAGE. Please make as simpleas possible.

Explanation / Answer

Answer for your question:

This matlab code will take the two parameters one is cash inserted into system and item price, based on the diffenece between cash inserted and item price. cash will dispense will be worked on below code.

function[dispense] = change12(cashinserted,itemprice)
%initial amounts of each coin
  
TotalAmount = cashinserted - itemprice
DollarsConversion 0;
Change = 0;
Dollars = 0;   
Hundreds = 0;
Fifties = 0;
Twenties = 0;
Tens = 0;
Fives = 0;
> CentsConversion = 0;
Cents;
Quarters = 0;
Dimes = 0;
Nickels = 0;
Pennies = 0;
  
DollarsConversion = TotalAmount * 100;
Hundreds = DollarsConversion / 10000;
Change = mod(DollarsConversion,10000);
Fifties = Change / 5000;
Change = mod(Change, 5000);
Twenties = Change / 2000;
Change = mode(Change,2000);
Tens = Change / 1000;
Change = mod(Change,1000);
Fives = Change / 500;
Change = mod(Change,500);
/ 100;
Change = mod(Change,100);

%Resets the Stack to calculate for the cents.
Dollars = TotalAmount;   
CentsConversion = TotalAmount * 1000;   
Dollars = Dollars * 1000;
Cents = CentsConversion - Dollars;

%Cents Calculation.
Quarters = Cents / 250;
Change = mod(Cents,250);
Dimes = Change / 100;
Change = mod(Change,100);
Nickels = Change / 50;
Change = mod(Change,50);
Pennies = Change / 10;
Change = mod(Change,10);
dispense = [Hundreds Fifties Twenties Tens Fives Ones Quarters Dimes Nickels Pennies];

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote