Question

In: Statistics and Probability

using math lab, Write a code to compute the change in dollars (no cents) to be...

using math lab, Write a code to compute the change in dollars (no cents) to be given back to a restaurant patron who pays the bill in cash. That is, find and enumerate the various combinations (of common currency notes only) that can amount to the change due.

Solutions

Expert Solution

ANSWER::

Here is the solution to your question. I tried my best to solve your doubt, however, if you find it is not as good as expected by you. Please do write your further doubts regarding this question in the comment section, I will try to resolve your doubts regarding the submitted solution as soon as possible.
If you think, the solution provided by me is helpful to you please do an upvote.

main.m
S=[1,2,5,10,20,50,100,500,1000]; % common notes in dollor
m=size(S,2)+1;
n=input("Enter the amount: ");
sol=combination(S,m,n);
fprintf("Number of combination of notes for the change of %d is, %d\n",n,sol);
combination.m
function ans=combination(S,m,n)
if n==0
ans=1;
return
endif
if n<0
ans=0;
return
endif
if m<=1 && n>=1
ans=0;
return
endif
ans= combination(S,m-1,n)+combination(S,m,n-S(m-1));
return
endfunction
output

NOTE:: I HOPE YOUR HAPPY WITH MY ANSWER....***PLEASE SUPPORT ME WITH YOUR RATING...

***PLEASE GIVE ME "LIKE"...ITS VERY IMPORTANT FOR ME NOW....PLEASE SUPPORT ME ....THANK YOU


Related Solutions

Using the first code of this lab (Figure 1), write a code that displays the status...
Using the first code of this lab (Figure 1), write a code that displays the status of a push button on the LCD, that is, when you press it you should see “Pushed” on the LCD and when you release it, you should see “Released” #include <LiquidCrystal.h> // initialize the library with the numbers of the interface pins LiquidCrystal lcd(12, 11, 5, 4, 3, 2); void setup() { // set up the LCD's number of columns and rows: lcd.begin(16, 2);...
Using the information below, compute ending retained earnings. Write your answer in dollars. (Do not write...
Using the information below, compute ending retained earnings. Write your answer in dollars. (Do not write the dollar sign.)                                   Additional Paid-in Capital, Common    $ 9,000                                   Accounts Payable    1,100                                   Total Expenses                                     7,800                                   Preferred Stock, at par                     1,750                                   Common Stock, at par                                   400                                   Sales                                                      10,000                                   Treasury Stock                                        250                                   Dividends                                                 700                                   Retained Earnings (beginning)            1,000                                   Additional Paid-in Capital, Preferred    50
Using pseudocode or C++ code, write a function to compute and return the product of two...
Using pseudocode or C++ code, write a function to compute and return the product of two sums. The first is the sum of the elements of the first half of an array A. The second is the sum of the elements of the second half of A. The function receives A and N ≥ 2, the size of A, as parameters. (in c++)
write a java code program using loops to compute the sum of the 30 terms of...
write a java code program using loops to compute the sum of the 30 terms of the series below. Find sum of all integers between 100 and 200 which are divisible by 9 or 13 Write a program to find the sum of the first 8 terms of the series 1 + 11 + 111 + 1111 + . . . Output: Term Ratio Sum
Using vhdl in a FSM , how could you write code to delay a state change...
Using vhdl in a FSM , how could you write code to delay a state change for one hour? For example, you have a fan running in the 'on' state , but after 1 hour you would like that fan to switch back to the 'off' state. What is the best way going about doing this?
Using C++ code, write a program named q3.cpp to compute the total amount of medicine m...
Using C++ code, write a program named q3.cpp to compute the total amount of medicine m absorbed by a rabbit, where the rabbit gets 2 pills containing n1 and n2 grams of medicine, respectively, of which the rabbit absorbs 60% and 35%, respectively, and n1 and n2 are input by a user via the keyboard.  
Using C++ code, write a program named q3.cpp to compute the total amount of medicine m...
Using C++ code, write a program named q3.cpp to compute the total amount of medicine m absorbed by a rabbit, where the rabbit gets 2 pills containing n1 and n2 grams of medicine, respectively, of which the rabbit absorbs 60% and 35%, respectively, and n1 and n2 are input by a user via the keyboard.
The number of students using the math lab per day is found in the distribution below....
The number of students using the math lab per day is found in the distribution below. Find the mean, variance, and standard deviation for this probability distribution ? 6 8 10 12 14 ?(?) 0.15 0 0.35 0.1 … Find the (i) Missing probability
using Visual Studio write a code containing a main() program that implements the coin change state...
using Visual Studio write a code containing a main() program that implements the coin change state machine in C++ according to the guidance given in Translating a state machine to C++ Test your code using prices 1 and 91 cents, and assume change is calculated from a dollar bill. Copy and paste your console output to a text editor and save the result in a single file named console.txt. Upload your exercise081.cpp and console.txt files to Canvas.
write a java code Write a generic program to compute the sum of 30 terms of...
write a java code Write a generic program to compute the sum of 30 terms of the following series. (181 - 5)/31 + (186 + 9)/34 - (191 - 13)/37 + (196 + 17)/40 + . . . . . 1 5 11 Note: the 3rd, 6th, 9th term etc, has a negative sign in front of parenthesis. User Input: None Expected output: Term Ratio Sum 1 5.677 5.677 2 5.735 11.413 3 -4.811 6.602
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT