Help with deleting lines

I am writing a program that gives you the least amount of change when you type in a number. It is sort of a change calculator. What the program currently does is give out the correct change but for the unused coins it shows and output of 0. What I want it to show is just the used coins and the unused ones to not show up. I'm told that this can be achieved with IF statements but I have not learned how to fully use them to do this.

Here is my code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include <iostream>
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."<<endl;
	cout<<"Input the total here: ";
	cin>> DollarAmt >> DecimalPoint >> DecimalAmt;
	cout<<endl;

	TotalMoneyInPennies = DecimalAmt + (DollarAmt * PENNIES_TO_DOLLAR);

	cout<<"You input: $"<< DollarAmt << DecimalPoint << DecimalAmt<<endl;

	cout<<"This is a total of " <<TotalMoneyInPennies <<" pennies."<<endl;

	cout<<"Your denominations would be: "<<endl;

	cout<< "Fifties: "<<TotalMoneyInPennies/FIFTIES<<endl;
	TotalMoneyInPennies = TotalMoneyInPennies % FIFTIES;

	cout<< "Twenties: "<<TotalMoneyInPennies/TWENTIES<<endl;
	TotalMoneyInPennies = TotalMoneyInPennies % TWENTIES;

	cout<< "Tens: "<<TotalMoneyInPennies/TENS<<endl;
	TotalMoneyInPennies = TotalMoneyInPennies % TENS;

	cout<< "Fives: "<<TotalMoneyInPennies/FIVES<<endl;
	TotalMoneyInPennies = TotalMoneyInPennies % FIVES;

	cout<< "Toonies: "<<TotalMoneyInPennies/TWOS<<endl;
	TotalMoneyInPennies = TotalMoneyInPennies % TWOS;

	cout<< "Loonies: "<<TotalMoneyInPennies/ONES<<endl;
	TotalMoneyInPennies = TotalMoneyInPennies % ONES;

	cout<< "Quarters: "<<TotalMoneyInPennies/QUARTER<<endl;
	TotalMoneyInPennies = TotalMoneyInPennies % QUARTER;

	cout<< "Dimes: "<<TotalMoneyInPennies/DIME<<endl;
	TotalMoneyInPennies = TotalMoneyInPennies % DIME;

	cout<< "Nickels: "<<TotalMoneyInPennies/NICKEL<<endl;
	TotalMoneyInPennies = TotalMoneyInPennies % NICKEL;
	
	cout<< "Pennies: "<<TotalMoneyInPennies<<endl;

	system ("pause");
}
closed account (18hRX9L8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include <iostream>
using namespace std;

int main()
{
     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;
	float DollarAmt;
	int TotalMoneyInPennies;

	cout<<"This program will convert a total amount of money into denominations of money to make change."<<endl;
	cout<<"Input the total here: ";
	cin>> DollarAmt;
	cin.ignore();
	cout<<endl;
	DollarAmt = DollarAmt + 0.001;

	TotalMoneyInPennies = DollarAmt * PENNIES_TO_DOLLAR;

	cout<<"You input: $"<< DollarAmt - 0.001 << endl;

	cout<<"This is a total of " <<TotalMoneyInPennies <<" pennies."<<endl;

	cout<<"Your denominations would be: "<<endl;
     
     if(TotalMoneyInPennies/FIFTIES!=0){
	cout<< "Fifties: "<<TotalMoneyInPennies/FIFTIES<<endl;
	TotalMoneyInPennies = TotalMoneyInPennies % FIFTIES;}
	
     if(TotalMoneyInPennies/TWENTIES!=0){
	cout<< "Twenties: "<<TotalMoneyInPennies/TWENTIES<<endl;
	TotalMoneyInPennies = TotalMoneyInPennies % TWENTIES;}

     if(TotalMoneyInPennies/TENS!=0){
	cout<< "Tens: "<<TotalMoneyInPennies/TENS<<endl;
	TotalMoneyInPennies = TotalMoneyInPennies % TENS;}

     if(TotalMoneyInPennies/FIVES!=0){
	cout<< "Fives: "<<TotalMoneyInPennies/FIVES<<endl;
	TotalMoneyInPennies = TotalMoneyInPennies % FIVES;}

     if(TotalMoneyInPennies/TWOS!=0){
	cout<< "Toonies: "<<TotalMoneyInPennies/TWOS<<endl;
	TotalMoneyInPennies = TotalMoneyInPennies % TWOS;}

     if(TotalMoneyInPennies/ONES!=0){
	cout<< "Loonies: "<<TotalMoneyInPennies/ONES<<endl;
	TotalMoneyInPennies = TotalMoneyInPennies % ONES;}

     if(TotalMoneyInPennies/QUARTER!=0){
	cout<< "Quarters: "<<TotalMoneyInPennies/QUARTER<<endl;
	TotalMoneyInPennies = TotalMoneyInPennies % QUARTER;}
	
     if(TotalMoneyInPennies/DIME!=0){
	cout<< "Dimes: "<<TotalMoneyInPennies/DIME<<endl;
	TotalMoneyInPennies = TotalMoneyInPennies % DIME;}

     if(TotalMoneyInPennies/NICKEL!=0){
	cout<< "Nickels: "<<TotalMoneyInPennies/NICKEL<<endl;
	TotalMoneyInPennies = TotalMoneyInPennies % NICKEL;}
	
	if(TotalMoneyInPennies!=0){
	cout<< "Pennies: "<<TotalMoneyInPennies<<endl;}

	cin.ignore();
}


Don't use system(); . It's a security hazard and uses extra memory.
Thank you this works flawlessly
I need C++ program of calculator that solve such an expression
10*(24/(5-2))+13
Topic archived. No new replies allowed.