1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
hjlf
2 years ago
15

Write a function [change,flag] = makeChangeRecursive(cost,paid) that takes the cost of an item cost (a 1x1 double) and the amoun

t paid by the buyer paid (a 1x1 double), and returns a n x 1 column array of doubles change containing the bills that the seller should give back to the buyer in decreasing order and flag a 1x1 logical true or false saying whether the transaction was "completed". If paid is less than cost, flagis false and you should display a warning in the command window saying "That's not enough to buy that item." and change is assigned as an empty array. If cost and paid are equal the change is assigned as an empty array and flag is true. If paid is greater than cost, flag is true and change is the difference between the two made by combining the denominations: 100, 50, 20, 10, 5, 2, and 1.
Computers and Technology
1 answer:
vaieri [72.5K]2 years ago
5 0

Answer:

The answer to this question can be given as:

function [change,flag]=makeChangeRecursive(cost,paid)          

//define function

change=[];    

flag=false;                  //use flag for true or false.

if((paid-cost)>=100)         //checking condition value greater then equal to 100

[m,f]=makeChangeRecursive(cost,paid-100);

change=[100;m];

flag=true;

return;

elseif((paid-cost)>=50)     //checking condition value greater then equal to 50

[m,f]=makeChangeRecursive(cost,paid-50);       //holding value.

change=[50;m];    

flag=true;

return;

elseif((paid-cost)>=20)    //checking condition value greater then equal to 20

[m,f]=makeChangeRecursive(cost,paid-20);

change=[20;m];

flag=true;

return;

elseif((paid-cost)>=10)      //checking condition value greater then equal to 10

[m,f]=makeChangeRecursive(cost,paid-10);

change=[10;m];

flag=true;

return;

elseif((paid-cost)>=5)         //checking condition value greater then equal to 5

[m,f]=makeChangeRecursive(cost,paid-5);

change=[5;m];    

flag=true;

return;

elseif((paid-cost)>=2)   //checking condition value greater then equal to 2

[m,f]=makeChangeRecursive(cost,paid-2);

change=[2;m];

flag=true;

return;

elseif((paid-cost)>=1)  //checking condition value greater then equal to 1

[m,f]=makeChangeRecursive(cost,paid-1);

change=[1;m];    

flag=true;

return;

elseif((paid-cost)<0)                        //checking condition value less then 0

warning('That''s not enough to but an item.');         //print message

flag=false;

return;

elseif(paid==cost)               //checking condition if value is equal.

flag=1;                                   //falg value.

change=[];

return;    

end                              

end        //end function

Explanation:

In the above program code the function must use the recursion to change the variable.This function run in 4 case i.e. case 1  In this case when we pass the  value [change,flag]=makeChangeRecursive(2,100) in the function so the change value will be 50,20,20,5,2,1,and flag= ,1. In case 2 when we pass the value(3,20) in the function so the change value will be 10,5,2,and flag= ,1. In case 3 when we pass the value(20,20) in the function so the change value will be change= {},flag= 1. In case 4 when we pass the value(59,20) in the function so the change value will be warning message i.e That''s not enough to but an item.

You might be interested in
How does the discussion of “Luddites,” “Marx,” and “John Maynard Keynes” in paragraph 21 contribute to the development of the id
gavmur [86]

Answer:

d

Explanation:

6 0
3 years ago
A company has a file server that shares a folder named Public. The network security policy specifies that the Public folder is a
klasskru [66]

Answer:

authentication

Explanation:

At the authentication process, there is a way of identifying a user, this is typically done by having the user enter a valid user name and valid password before access is granted. Here at authentication the process is based on each user having a unique set of criteria for gaining access.

The AAA server have to ascertain by comparing a user's authentication credentials with other user credentials stored in a database. In the event the credentials match, the user is granted access to the network. But on the other hand, If the credentials varies, and authentication fails then network access will be denied.

3 0
3 years ago
Javier develops sophisticated fashion websites. He has been asked by the owner of a leading fashion brand to create web content
saul85 [17]

Answer:

hyperlinks

Explanation:

Javier should use hyperlinks to show the users the possible choices for their clothing.  This is really a terrible question and not likely in any real world scenario.  Fashion is always forward thinking and on the cutting edge.  When was the last time you went to a fashion website and were left with only choices to click on a hyperlink?  As Tim Gun would say "Make it work."  If I were able I would include a hyperlink using the previous sentence as the clickable link with a URL reference to

https : //en.wikipedia.org/wiki/Tim_Gunn (spaces after https to make this link not get censored)

to illustrate the way to show that hyperlinks have no real application on modern fashion website.  But they would have great utility here inside the answers section.  But they also are cause for a securtity concern and may be killed by the moderators

7 0
3 years ago
Hello can you please help with this if you want to thank you!
nikklg [1K]

Answer:

hardware and software is the answer

8 0
2 years ago
Read 2 more answers
Complete the sentence to identify disadvantages of top-down programming design. Choose all that apply. Top-down programming desi
pav-90 [236]

so is it all about codes and codes and codes and codes and codes lol

4 0
3 years ago
Other questions:
  • Two or more computers that transfer information between computers are called a
    7·1 answer
  • What is the seventh byte in the roller coasters file?
    12·1 answer
  • ________ is a dedicated device designed to manage encrypted connections established over an untrusted network such as the Intern
    12·1 answer
  • Type the correct answer in the box.
    15·1 answer
  • Where does the list of incoming mail appear in gmail
    13·2 answers
  • While (e &lt; 10):<br> print (c)
    10·1 answer
  • Why is simplicity important in navigation design?
    13·1 answer
  • Write a program that displays the middle value of three unduplicated input values. Hint: Review the four solutions in the smalle
    10·1 answer
  • Question 8 (True/False Worth 3 points)
    15·1 answer
  • I need help about computer program. Solve C language code...... please​
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!