Write a program that converts change into formatted dollars and cents It should do the following:  Prompt the user for their change in Quarters, Dimes, Nickels, and Pennies Read the associated integers from the keyboard Calculate the result Use printf to display the output as $d.cc A sample run with inputs 6, 5, 4, 3 must look like: (plural is ok even when grammatically incorrect)   Enter the number of quarters:  6 Enter the number of dimes:     5 Enter the number of nickels:   4 Enter the number of pennies:   3 You entered:    6 quarters     5 dimes     4 nickels     3 pennies The total in dollars is $2.23   A sample run with inputs 1, 2, 3, 2 must look like:   Enter the number of quarters:  1 Enter the number of dimes:     2 Enter the number of nickels:   3 Enter the number of pennies:   2 You entered:    1 quarters     2 dimes     3 nickels     2 pennies The total in dollars is $0.62 Hint: Use printf to ensure there is at least 1 digit to the left of the decimal point and at most 2 digits to the right.   Please make sure to end each line of output with a newline.   Please note that your class should be named ChangeConverter.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter5: Control Structures Ii (repetition)
Section: Chapter Questions
Problem 28PE
icon
Related questions
Question

Write a program that converts change into formatted dollars and cents

It should do the following: 

  1. Prompt the user for their change in Quarters, Dimes, Nickels, and Pennies
  2. Read the associated integers from the keyboard
  3. Calculate the result
  4. Use printf to display the output as $d.cc



A sample run with inputs 6, 5, 4, 3 must look like: (plural is ok even when grammatically incorrect)

 

Enter the number of quarters:  6

Enter the number of dimes:     5

Enter the number of nickels:   4

Enter the number of pennies:   3

You entered:

   6 quarters 

   5 dimes 

   4 nickels 

   3 pennies

The total in dollars is $2.23

 

A sample run with inputs 1, 2, 3, 2 must look like:

 

Enter the number of quarters:  1

Enter the number of dimes:     2

Enter the number of nickels:   3

Enter the number of pennies:   2

You entered:

   1 quarters 

   2 dimes 

   3 nickels 

   2 pennies

The total in dollars is $0.62



Hint: Use printf to ensure there is at least 1 digit to the left of the decimal point and at most 2 digits to the right.

 

Please make sure to end each line of output with a newline.

 

Please note that your class should be named ChangeConverter

AI-Generated Solution
AI-generated content may present inaccurate or offensive content that does not represent bartleby’s views.
steps

Unlock instant AI solutions

Tap the button
to generate a solution

Knowledge Booster
Mathematical functions
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr