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

Topic: Artificial intelligence ( Artificial intelligence in society) Assignment: You are expected to submit a typed,...
Topic: Artificial intelligence ( Artificial intelligence in society) Assignment: You are expected to submit a typed, formal, full-sentence outline for your presentation. Consult notes from our class discussion on organization and outlining and the appropriate sections of the textbook for more information. Please also see the Informative Speech Formal Outline Example posted in Canvas in the section of Supplemental Materials. You must submit a typed, formal, full-sentence outline for your Informative speech in order for your Informative Speech to be...
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
Artificial Intelligence Question. This topic is about AI representation stochastic methods. I will like it if...
Artificial Intelligence Question. This topic is about AI representation stochastic methods. I will like it if this is good explained and answer Represent the robot arm problem from earlier sections as a production system. For simplicity use the basic representation that doesn’t care exactly where the blocks are, just if they’re stacked or not. It will only be given four blocks a, b, c, d in some configuration and have to move them until a goal configuration is reached.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT