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
3 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]3 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
oe, a user, receives an email from a popular video streaming website. the email urges him to renew his membership. the message a
ale4655 [162]

Where Joe, a user, receives an email from a popular video-streaming website and the email urges him to renew his membership. If the message appears official, but Joe has never had a membership before, and if when Joe looks closer, he discovers that a hyperlink in the email points to a suspicious URL, note that the security threat that this describes is: "Phishing" (Option B)

<h3>What is Phishing?</h3>

Phishing is a sort of social engineering in which an attacker sends a fake communication in order to fool a person into disclosing sensitive data to the perpetrator or to install harmful software, such as ransomware, on the victim's infrastructure.

To avoid phishing attacks, make sure you:

  • understand what a phishing scheme looks like
  • Please do not click on that link.
  • Get anti-phishing add-ons for free.
  • Don't provide your information to an untrusted website.
  • Regularly change passwords.
  • Don't disregard those updates.
  • Set up firewalls.
  • Don't give in to those pop-ups.

Learn more about Phishing:
brainly.com/question/23021587
#SPJ1

Full Question:

Joe, a user, receives an email from a popular video streaming website. The email urges him to renew his membership. The message appears official, but Joe has never had a membership before. When Joe looks closer, he discovers that a hyperlink in the email points to a suspicious URL.

Which of the following security threats does this describe?

  • Trojan
  • Phishing
  • Man-in-the-middle
  • Zero-day attack
5 0
2 years ago
Explain the steps users can take to maintain an operating system
Mars2501 [29]

First is it to always clean out all the junk that is left behind by the operating system and the browsers. You can easily do this using the Disk Cleanup utility included on the windows systems. You can clean up the registry. However, you should be very careful with the registry. Any wrong move might mess up everything


Search and destroy viruses and malware on your PC by installing an anti-virus security program and setting up an automated maintenance schedule.


Defragment main and partitioned drives to keep your computer running smoothly.


Uninstall software programs and personal files like pictures, movies and music that are no longer in use to free up more space. The more the space, the faster the PC will go. You can also run the msconfig command in the RUN command prompt to uncheck start up programs that you do not use

4 0
3 years ago
You do not need to use any functions beyond the main function in this problem. Initialize an array of int with the values: 4, 6,
zheka24 [161]

Answer:

import java.util.Scanner;

public class Main

{

public static void main(String[] args) {

   

    int[] arr = {4, 6, 9, 12};

    int sum = 0;

   

    for(int i=0; i<arr.length; i++){

        sum += arr[i];

    }

   

    for(int i=0; i<arr.length; i++){

        System.out.print(arr[i] + " ");

    }

    System.out.println("");

 System.out.println("The sum of the numbers: " + sum);

}

}

Explanation:

* The code is written in Java.

- Initialize the array with the given numbers

- Initialize the <em>sum</em> variable as zero

- Calculate the sum in the first for loop

- Print the numbers in the second for loop

- Print the <em>sum</em>

4 0
3 years ago
Give three reasons why you think Clip Art is so widely used in many different types of documents.
irinina [24]
Well Here Are Some Advantages To Clip Art,
There Is A Large Variety Of Clip Art To Choose From.
You Don't Need To Buy Any Special Equipment Like A Scanner.
It Takes No Artistic Skills To Produce.
Most Clip Art Is Royalty And Copyright Free.
It Doesn't Have To Be Developed From Scratch.
Hope I Helped
6 0
3 years ago
Read 2 more answers
Best practices and trends for technology integration
cluponka [151]

Answer:

Technology use must be aligned to the standards. Technology must be integrated into daily learning,

Explanation:

Technology use must be aligned to the standards. Technology must be integrated into daily learning, not used as an add-on to instruction to match personal learning needs. Students need opportunities to use technology collaboratively. Technology must support project based learning and include real-world simulations.

3 0
2 years ago
Other questions:
  • What are factors that limit a technological design
    13·1 answer
  • Consider the following implementation of a class Square:
    12·1 answer
  • Write a function "nonRepeatings" that takes a string "s3" and returns the non-repeating characters in this string. Sample Input
    11·1 answer
  • Is the following statement TRUE or FALSE?
    9·1 answer
  • Does anyone know the answer for this? I’m extremely confused.
    8·2 answers
  • what are the benefits of VolP? select all that apply. A:cheaper printings B:clearer calls C: faster download D: increased effici
    11·2 answers
  • One lap around a standard high-school running track is exactly 0.25 miles. Write a program that takes a number of miles as input
    12·1 answer
  • Difference between a port and a connector
    10·1 answer
  • Cite some improved technology this 2021?
    5·1 answer
  • What are backup storage devices of computer? Why are they necessary in the computer system?​
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!