Numbers before my output.

I keep getting a list of ordered numbers before my ouuput.
it looks like this:
1 The amount spent for Restaurants is $171.19
2 The amount spent for Groceries is $440.95
3 The amount spent for Gas is $185.85
4 The amount spent for Entertainment is $151.27
5 The amount spent for Mortgage is $1049.00
6 --------------------------------------------------------------------
7 The total amount spent was $1998.26
8 The number of debit charges was: 30
9 The following bar graph shows a visual representation of how much was spent in each category.
10 Each * represents $25
11 ******
12 *****************
13 *******
14 ******
15 *****************************************


I need it to go away, cannot seem to find the code thats making it numbered.

Also, would i use a nested while loop for my consecutive loops?

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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
 #include <iostream>
#include <fstream>
#include <iomanip>
#include <stdlib.h>
#include <cmath>

using namespace std;

int main()
{
	//declare variables section
	
	
	ifstream inData;
	ofstream outData;
	string inputFile;
	string outputFile;
	string category;
	float num1,totalR=0,totalGr=0,totalGa=0,totalEn=0,totalMo=0;
	
	
	
	cout << "Enter the input data file name: " << endl;
	cin >> inputFile;
	inData.open(inputFile.c_str());
	if (!inData)
	{
		cout<< "Can't open the input file. Program is stopping." << endl;
		return 1;
	}  
	
	cout << "Enter the name of the file where you want the results stored: " << endl;
	cin >> outputFile;
	outData.open(outputFile.c_str());   
	

	

	inData.ignore(100,'c');
	inData >> category;
	int count=0;
	
	while (inData)
	{	
		
		
		if (category == "Restaurant")
		{ 
		inData.ignore(500, '$');
		inData >> num1;
		totalR= totalR+num1;
			count++;
		}
		
	
		
	 else if (category=="Groceries")
		{	inData.ignore(500, '$');
			inData >> num1;
			totalGr=totalGr+num1;
			count++;
			
		}
		else if (category == "Gas")
		{ inData.ignore(500, '$');
			inData >> num1;
			totalGa= totalGa+num1;
			count++;
		}
		else if (category == "Entertainment")
		{ inData.ignore(500, '$');
			inData >> num1;
			totalEn= totalEn+num1;
			count++;
		}  
		else if (category == "Mortgage")
		{ inData.ignore(500, '$');
			inData >> num1;
			totalMo= totalMo+num1;
			count++;
		}  
	inData >> category;
		
	}
	
	outData << "The amount spent for Restaurants is $" << fixed << setprecision(2) << totalR << endl;
	outData << "The amount spent for Groceries is $" << fixed << setprecision(2) << totalGr << endl;
	outData << "The amount spent for Gas is $" << fixed << setprecision(2) << totalGa << endl;
	outData << "The amount spent for Entertainment is $" << fixed << setprecision(2) << totalEn << endl;
	outData << "The amount spent for Mortgage is $" << fixed << setprecision(2)<< totalMo << endl;
	outData << "--------------------------------------------------------------------" << endl;
	outData << "The total amount spent was $" << fixed << setprecision(2) << totalR+totalGr+totalGa+totalEn+totalMo << endl;
	outData << "The number of debit charges was: " << count << endl;
	
	outData << "The following bar graph shows a visual representation of how much was spent in each category." << endl;
	outData << "Each * represents $25" << endl;
	
	


	int starcount=1;
	int number=(int)totalR/25;
	 while(starcount <= number) 
	 
	{
		outData <<"*";
		starcount++;
	
	}
	outData<<endl;

	 int star2count=1;
	int number2=(int)totalGr/25;
	 while(star2count <= number2) 
	
	{
		outData <<"*";
		star2count++;
	}
		
	outData<<endl;
	
	int star3count=1;
	int number3=(int)totalGa/25;
	 while(star3count <= number3) 
	
	{
		outData <<"*";
		star3count++;
	
	}
	outData<<endl;
	
	int star4count=1;
	int number4=(int)totalEn/25;
	 while(star4count <= number4) 
	
	{
		outData <<"*";
		star4count++;
	
	}
	outData<<endl;
	
	int star5count=1;
	int number5=(int)totalMo/25;
	 while(star5count <= number5) 
	
	{
		outData <<"*";
		star5count++;
	
	}
	outData<<endl;
			

	
	
		

	
	
return 0;
}
Last edited on
I'm going to make a wild guess that it's the editor your using not the program. If that is not correct, give me a sample of your input so I can test it.
Topic archived. No new replies allowed.