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
Instructions Complete the lab using “for loop”. Do not write the code in multiple programs. All...
Instructions Complete the lab using “for loop”. Do not write the code in multiple programs. All the 3 methods should be written in 1 program. Write a java program calls the following methods: printStars(): Takes an int (n) as parameter and prints n stars (*) using for loop. Multiples(): Takes an int (n) as parameter and prints first 10 multiples n in a single line using for loop. hasAnEvenDigit: Takes an int (n) as parameter and returns whether n has...
22.8 LAB 5 D FALL 19 : Using math functions This lab problem demonstrates the use...
22.8 LAB 5 D FALL 19 : Using math functions This lab problem demonstrates the use of import module. The Python programming language has many strengths, but one of its best is the availability to use many existing modules for various tasks, and you do not need to be an experienced computer programmer to start using these modules. We have given you some incomplete code; note that the very first line of that code contains an import statement as follows:...
Note: Present results using fprintf()and comment your code throughout. Write a function that will compute the...
Note: Present results using fprintf()and comment your code throughout. Write a function that will compute the volume and surface area of a rectangular prism when provided with the object’s 3 numerical dimensions. In other words, the function should be given three inputs (height, width and depth) and return two outputs (the volume and surface area, in that order). Show the following test cases: height: 5   width:3    depth: 2 heignt:1    width:8    depth:4 height: 2   width:2    depth:10 The script should call the...
Suppose that we want to make change for n cents using the least number of coins....
Suppose that we want to make change for n cents using the least number of coins. The coins are of denominations c 0 , c 1 , . . . , c k for some integers c > 1, and k ≥ 1. (a) Design a greedy algorithm to solve this problem. (b) Prove that your algorithm finds an optimal solution by showing the greedy-choice property and optimal substructure for it. Clearly state each property and then prove them.
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?
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
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT