Question

In: Computer Science

You should read this question as if the change giver is an artificial intelligence-based bank teller...

You should read this question as if the change giver is an artificial intelligence-based bank teller who has to give amounts of money to customers by automatically working out the amounts. You are asked to write a modular solution (algorithm and C program) that will accept an integer value in the range of 5-95 inclusive. Your solution should also ensure that input values are in multiples of 5. Based on valid input, your solution should calculate how many coins of each denomination should be returned, and display this to the user. Coin values are 50, 20, 10 and 5. The solution should aim to give as much of the higher valued coins as possible. For example, a poor solution for an input of 30 cents would give six 5 cent coins. A correct solution would give a 20 cent coin and a 10 cent coin. After each output, the user should be asked whether they wish to continue or exit/terminate the program. Your solution (algorithm and program) should be designed using a modular approach. This requires the submission of a structure chart, a high-level algorithm, and subsequent decompositions of each step (i.e. low-level algorithms). Hint 1- multple of 5 condition. 2- do while loop in switch to terminate the question. 3- no of input is divisible of 5

Solutions

Expert Solution

Hey,

Please comment  if you have any doubt or you need to know it detail....Hope this help you!!!!!....Do like ...

Have a happy day buddy.....

C PROGRAM

#include <stdio.h>

int getData()

{

int totalChange;

printf ("Please insert amount of change required:\n");

scanf ("%d%*c", &totalChange);

return(totalChange);

}

int Check(int totalChange)

{

const int MAXCHANGE = 95;

const int MINCHANGE = 5;

int valid;

if (totalChange > MAXCHANGE || totalChange < MINCHANGE)

{

printf ("Please insert a value greater then 5 and less then 95\n");

valid = 1;

}

else if(totalChange%5!=0)

{

printf ("Please insert a value of multiple of 5\n");

valid=1;

}

return(valid);

}

int Change(int totalChange, int cent)

{

int t, counter = 0;

while (totalChange >= cent)

{

t= (totalChange%cent);

if(t==0)

{

counter=(totalChange/cent);

printf ("\n%d = %d\n", cent, counter);

return(t);

}

counter=(totalChange/cent);

totalChange=t;

printf ("\n%d = %d\n", cent, counter);

}

return (totalChange);

}

int main()

{

  int totalChange, fiftyC, twentyC, tenC, fiveC, valid,ch;

  const int FIFTYCENT = 50;

  const int TWENTYCENT = 20;

  const int TENCENT = 10;

  const int FIVECENT = 5;

do

{

totalChange = getData ();

valid = Check (totalChange);

if (valid != 1)

{

fiftyC= Change (totalChange, FIFTYCENT);

twentyC= Change ( fiftyC, TWENTYCENT);

tenC= Change (twentyC, TENCENT);

fiveC= Change (tenC, FIVECENT);

}

printf ("Do you want to continue(1/0)::");

scanf("%d",&ch);

}while(ch==1);

return (0);

}

output::


Related Solutions

1)  What should be the definitions of “intelligence” and “artificial intelligence” 2) Can machines think?
1)  What should be the definitions of “intelligence” and “artificial intelligence” 2) Can machines think?
Artificial Intelligence and Cognitive Psychology How can you engineer human emotion in artificial intelligence? Do not...
Artificial Intelligence and Cognitive Psychology How can you engineer human emotion in artificial intelligence? Do not copy and paste from other websites without giving credit or putting things in quotes. For example, don't say it is possible to engineer human emotion by using engineering principles. What kind of engineering principles? How does engineering even come into the picture?
Would you expect technological change and artificial intelligence to increase the level of unemployment? Explain 2...
Would you expect technological change and artificial intelligence to increase the level of unemployment? Explain 2 factors that might lessen the effect on unemployment?      2 Marks
Artificial Intelligence question: Why might we prefer the cross-entropy as an error function in a sigmoid-based...
Artificial Intelligence question: Why might we prefer the cross-entropy as an error function in a sigmoid-based network?
Question: What are the impact of Virtual and augmented reality and Machine learning and artificial intelligence...
Question: What are the impact of Virtual and augmented reality and Machine learning and artificial intelligence on the following questions relating to the healthcare industry? ?? Can it lower the cost of maintaining your legacy systems? Will it enable your organization to improve business processes? Will it improve interoperability of systems? Will it simplify or standardize IT interfaces? Does it define new computing or communication standards? Can this technology be used to re-engineer a mission-critical business process? Will employees see...
The subject area of expert (knowledge based) systems is a branch of artificial intelligence (AI); which...
The subject area of expert (knowledge based) systems is a branch of artificial intelligence (AI); which in turn is a branch of computer science that attempts to understand the nature of intelligence and produce new classes of intelligent machines. Considering the fields of engineering or business, demonstrate with five (5) practical diagrams and explain how they represent new classes of intelligence. [
Should Robotics and Artificial Intelligence (AI) be implemented in all health care settings? write in more...
Should Robotics and Artificial Intelligence (AI) be implemented in all health care settings? write in more than 500 words
1. Should we be afraid of future Artificial Intelligence? 2. What kinds of technology pose the...
1. Should we be afraid of future Artificial Intelligence? 2. What kinds of technology pose the greatest threat (automated robotics, super computers, cyborgs, androids)? 3.What kinds of technology are essential to develop (e.g.robot surgeons, automated factory workers)? i need answers for all 3 please explain with examples
What are some positive impacts of the implementation of artificial intelligence or machine learning that you...
What are some positive impacts of the implementation of artificial intelligence or machine learning that you could use with fund accounting to counteract the issues of agency readiness, budgetary constraints, or security?
Research Essay Question As technological advances and artificial intelligence play an increasingly prominent role in modern...
Research Essay Question As technological advances and artificial intelligence play an increasingly prominent role in modern organisations, is Taylor's Scientific Management more or less relevant today and into the future than it was in the 20th century? Your answer to this question should be based on your research and should be supported by relevant examples.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT