### Eliminating lines with if statements

This program calculates the least amount of change a person can give. For example if I would type in \$26.50 it would print out -
Twenties-1
Fives- 1
Loonies-1
Quarters-2

Also for the bills and coins not used how would I get the to not show instead of the giving me zeros.

 ``1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465`` ``````#include using namespace std; const int FIFTIES = 5000; const int TWENTIES = 2000; const int TENS = 1000; const int FIVES = 500; const int TWOS = 200; const int ONES = 100; const int QUARTER = 25; const int DIME = 10; const int NICKEL = 5; const int PENNIES_TO_DOLLAR = 100; int main() { int DollarAmt, DecimalAmt; char DecimalPoint; int TotalMoneyInPennies; cout<<"This program will convert a total amount of money into denominations of money to make change."<> DollarAmt >> DecimalPoint >> DecimalAmt; cout<
Last edited on
First calculate the value it should be, e.g. `int fifties = TotalMoneyInPennies/FIFTIES;`. Then check whether fifties <= 0. If not, do the cout statement. Otherwise only calculate the TotalMoneyInPennies.
Topic archived. No new replies allowed.