Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

For this assignment, you will write a program that will make change for any doll

ID: 3546002 • Letter: F

Question

For this assignment, you will write a program that will make change for any dollar value, within reason. The largest denomination you will use is a $100.00 bill, and the smallest coin is a penny (of course). There are many ways to make change, so I want your program to make change using the smallest number of commonly used bills. For example, for $80 you could use four $20 bills, but I want you to use one $50 bill, one $20 bill, and one $10 bill. As another example, say you want to make change for $264.32. Your program will tell you that it

Explanation / Answer

#include<iostream.h>

#include<conio.h>

void main()

{

float a;

cout<<"Welcome to Rob's change maker!

This program will tell you the bills and the coins

necessary to make change for any reasonable dollar amount.

What dollar value would you like to make change for?"<<endl;

cin>>a;

int c[10];

if(a>100)

{

c[0]=a/100;

cout<<" "<<c[0]<<" hundreds";

a=a%100;

}

if(a>50)

{

c[1]=a/50;

cout<<" "<<c[1]<<" fifties";

a=a%50;

}

if(a>20)

{

c[2]=a/20;

cout<<" "<<c[2]<<" twenties";

a=a%20;

}

if(a>10)

{

c[3]=a/10;

cout<<" "<<c[3]<<" tens";

a=a%10;

}

if(a>5)

{

c[4]=a/5;

cout<<" "<<c[4]<<" fives";

a=a%5;

}

if(a>1)

{

c[5]=a/1;

cout<<" "<<c[5]<<" ones";

a=a%1;

}

if(a>0.25)

{

c[6]=a/0.25;

cout<<" "<<c[6]<<" quarters";

a=a%0.25;

}

if(a>0.10)

{

c[7]=a/0.10;

cout<<" "<<c[7]<<" dimes";

a=a%0.10;

}

if(a>0.05)

{

c[8]=a/0.05;

cout<<" "<<c[8]<<" nickels";

a=a%0.05;

}

if(a>0.01)

{

c[9]=a/0.01;

cout<<" "<<c[9]<<" pennies";

a=a%0.01;

}

getch();

}


Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote