This is a program to determine the fewest of each money denomination required to make change.
I'm stuck in the last part, I can't display correctly, the amount of nickels and pennies.

Thanks.

Input: Total amount of cents given by an user
Output: User's amount of cents converted in change using the fewest of each money denomination.

example: 299 cents

2 Dollars
1 Half Dollars
1 Quarter
2 Dimes
4 Pennies

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748`` ``````#include "stdafx.h" #include #include using namespace std; int main() { string name; double Total_amount_of_money, Remainder; double const One_Dollar = 100, Dollarv = 1, HDollarv = .50, Quarterv = .25, Dimev = .10, Nickelv = .05, Pennyv = .01; int Total_amount_of_cents, Dollars, Half_Dollars, Quarters, Dimes, Nickels, Pennies; cout << "This is a program to determine the fewest of each money denomination required\nto make change.\n"; cout << endl; cout << "Please enter your name: "; cin >> name; cout << endl; cout << "Hello," << name << ". Please enter your total amount of cents: "; cin >> Total_amount_of_cents; cout << endl; cout << Total_amount_of_cents << " cents is equal to: "; cout << endl; Dollars = Total_amount_of_cents / One_Dollar; cout << "Dollars: " <
Last edited on
C:\c.cpp: In function `int main()':
C:\c.cpp:22: warning: converting to `int' from `double'
C:\c.cpp:26: warning: converting to `int' from `double'
C:\c.cpp:29: warning: converting to `int' from `double'
C:\c.cpp:34: warning: converting to `int' from `double'
C:\c.cpp:38: warning: converting to `int' from `double'
C:\c.cpp:42: warning: converting to `int' from `double'
Process terminated with status 0 (0 minutes, 0 seconds)
0 errors, 6 warnings
pass
without " #include "stdafx.h" "
Last edited on
Hi...,
As your code states the Remainder value is always "0".

 ``1234`` ``````Dollars = Total_amount_of_cents / One_Dollar; .... .... Remainder = ((Total_amount_of_cents / One_Dollar) - Dollars);``````

Please focus into above lines of code.

Also if possible give one or two use cases, so that it is easier to analyze.
i.e. what is ur input and what are the expected output and current output.
Topic archived. No new replies allowed.