Answer to Question #159555 in C++ for Earl

Question #159555

You have a large collection of pennies and wish to change them into dollar bills at the bank, with quarters, dimes, nickels, and pennies being used for any remainder. Prompt for the number of pennies and produce output as shown below. 

  • Write the pseudo code 
  • Desk check 
  • Modify if necassary
  • Code
  • Compare output

Output:

How many pennies do you have (must be greater than 100)?     [Assume user inputs 641]

641 pennies can be changed at the bank as follows:

Dollars: 6

Quarters: 1

Dimes: 1

Nickels: 1

Pennies: 1


1
Expert's answer
2021-02-02T10:34:08-0500
#include <iostream>

using namespace std;

int main()
{
    int a;
    cout<<"How many pennies do you have (must be greater than 100)?\n";
    cin>>a;
    cout<<a<<" pennies can be changed at the bank as follows:\n";
    
    int D = a / 100;
    a -= 100 * D;
    
    cout<<"Dollars: "<<D<<"\n";
    
    int q = a / 25;
    a -= 25 * q;
    
    cout<<"Quarters: "<<q<<"\n";
    
    int d = a / 10;
    a -= 10 * d;
    
    cout<<"Dimes: "<<d<<"\n";
    
    int n = a / 5;
    a -= 5 * n;
    
    cout<<"Nickels: "<<n<<"\n";
    cout<<"Pennies: "<<a<<"\n";
    
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog