How to keep code from getting messy?

Hi guys! So I'm working on a program to help me close the register, divvy up credit card tips, compare till numbers, exc... its pretty messy. There are just so many values to store, convert, and compare! I'm really just ehhh. Should I have been using classes and objects this whole time? I shied away from that because I'm not quite comfortable with it yet.
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
#include<iostream>

using namespace std; 

int main()
{
	int response;
	int response1;
	int response2;
	int response3;
	bool bvalue = false;
	double cashtips = 0.0;
	int tipsplit = 0;
	double tipdiv = 0.0;
	int fone, ffiv, ften, ftwe, ffif, fhun, fpen, fnic, fdim, fqua, sone, sfiv, sten, stwe, sfif, 
		shun, spen, snic, sdim, squa, roll, tone, tfiv, tten, ttwe, tfif, thun, tpen, tnic, tdim, 
		tqua;
	double fones, ffivs, ftens, ftwes, ffifs, fhuns, fpens, fnics, fdims, fquas, sones, sfivs, stens, 
		stwes, sfifs, shuns, spens, snics, sdims, squas;
	double precash = 0.0;
	double precashsroll = 0.0;
	int swinput = 0;
	double cctips = 0.0;
	double deposit = 0.0;
	double countedcctips = 0.0;
	double registertotal = 0.0;

	cout << "\t\t\t *_*_* End Of Night *_*_* \n" << endl;
	cout << "Note: 1 = YES\n      2 = NO\n\nThis program does not guard against funky input! If you enter an 'a'\nwhere there should be a number, the program will CRASH! Use at your\nown risk.\n\n\n";
	do{
		cout << "Please enter the cash tips: ";
		cin >> cashtips;
		cout << "Is this the correct amount? " << cashtips << endl;
		cout << "(1/2):";
		cin >> response;
	} while (response == 2);

	cout << "How many people are splitting the tips?: ";
	cin >> tipsplit;

	tipdiv = cashtips / tipsplit;

	cout << "Proper amount each: " << tipdiv << endl;
	cout << "\nPlease enter the cash register amounts.\n";
	cout << "Ones:";
	cin >> fone;
	cout << "Fives:";
	cin >> ffiv;
	cout << "Tens:";
	cin >> ften;
	cout << "Twenties:";
	cin >> ftwe;
	cout << "Fifties:";
	cin >> ffif;
	cout << "Hundreds:";
	cin >> fhun;
	cout << "Pennies:";
	cin >> fpen;
	cout << "Nickels:";
	cin >> fnic;
	cout << "Dimes:";
	cin >> fdim;
	cout << "Quarters:";
	cin >> fqua;
	cout << "Rolled (enter amount of money total):";
	cin >> roll;

	cout << "Are you sure these totals are correct? You will not be able to go back if you're incorrect now (1/2):";
	cin >> response1;
	if (response1 == 1)
	{
		cout << "";
	}
	else if (response1 == 2)
	{
		cout << "Choose the value you would like to change.\n 1. ones\n 2. fives\n 3. tens\n 4. twenties\n 5. fifties\n 6. hundreds\n";
		cout << " 7. pennies\n 8. nickels\n 9. dimes\n 10. quarters\n 11. rolled\n 12. I lied, everythings fine\n";

		do{
			cin >> swinput;
			switch (swinput) {
			case 1:
				cout << "Ones:";
				cin >> fone;
				break;
			case 2:
				cout << "Fives:";
				cin >> ffiv;
				break;
			case 3:
				cout << "Tens:";
				cin >> ften;
				break;
			case 4:
				cout << "Twenties:";
				cin >> ftwe;
				break;
			case 5:
				cout << "Fifties:";
				cin >> ffif;
				break;
			case 6:
				cout << "Hundreds:";
				cin >> fhun;
				break;
			case 7:
				cout << "Pennies:";
				cin >> fpen;
				break;
			case 8:
				cout << "Nickels:";
				cin >> fnic;
				break;
			case 9:
				cout << "Dimes:";
				cin >> fdim;
				break;
			case 10:
				cout << "Quarters:";
				cin >> fqua;
				break;
			case 11:
				cout << "Rolled: ";
				cin >> roll;
				break;
			default:
				cout << "\nAnd so we continue!" << endl;
				break;
			}

			cout << "\nChange something else? (1/2):";
			cin >> response2;


		} while (response2 == 1);
	}

	else
	{
		cout << "" << endl;
	}

	fones = fone;
	ffivs = ffiv * 5;
	ftens = ften * 10;
	ftwes = ftwe * 20;
	ffifs = ffif * 50;
	fhuns = fhun * 100;
	fpens = fpen * .01;
	fnics = fnic * .05;
	fdims = fdim * .1;
	fquas = fqua * .25;
	precash = fones + ffivs + ftens + ftwes + ffifs + fhuns + fpens + fnics + fdims + fquas + roll;
	precashsroll = fones + ffivs + ftens + ftwes + ffifs + fhuns + fpens + fnics + fdims + fquas;

	cout << "\nCASH ON HAND WITH ROLLED: " << precash << endl;
	cout << "\nCASH ON HAND MINUS ROLLED: " << precashsroll << endl;

	cout << "\nPlease enter the total credit card tips: ";
	cin >> cctips;
	cout << "\nPlease enter the register total: ";
	cin >> registertotal;

	if (registertotal == precash)
		cout << "register and COH are equal :)" << endl;
	else if (registertotal < precash)
		cout << "You are under by " << precash - registertotal << endl;
	else if (registertotal > precash)
		cout << "You are over by" << registertotal - precash << endl;
	else
	{
		cout << "Comparison failed." << endl;
	}
	


	
	do{
	cout << "Please enter the bills and coins taken out for cash tips: \n";
	cout << "Ones:";
	cin >> sone;
	cout << "Fives:";
	cin >> sfiv;
	cout << "Tens:";
	cin >> sten;
	cout << "Twenties:";
	cin >> stwe;
	cout << "Fifties:";
	cin >> sfif;
	cout << "Hundreds:";
	cin >> shun;
	cout << "Pennies:";
	cin >> spen;
	cout << "Nickels:";
	cin >> snic;
	cout << "Dimes:";
	cin >> sdim;
	cout << "Quarters:";
	cin >> squa;


	sones = sone;
	sfivs = sfiv * 5;
	stens = sten * 10;
	stwes = stwe * 20;
	sfifs = sfif * 50;
	shuns = shun * 100;
	spens = spen * .01;
	snics = snic * .05;
	sdims = sdim * .1;
	squas = squa * .25;
	countedcctips = sones + sfivs + stens + stwes + sfifs + shuns + spens + snics + sdims + squas; 

}while (countedcctips != cctips);

	deposit = registertotal - cctips - roll; 
	cout << deposit << endl;

	cout << "\t\t\tPRE-TIPS" << endl;
	cout << "Ones:";
	cout << fone << endl;
	cout << "Fives:";
	cout << ffiv << endl;
	cout << "Tens:";
	cout << ften << endl;
	cout << "Twenties:";
	cout << ftwe << endl;
	cout << "Fifties:";
	cout << ffif << endl;
	cout << "Hundreds:";
	cout << fhun << endl;
	cout << "Pennies:";
	cout << fpen << endl;
	cout << "Nickels:";
	cout << fnic << endl;
	cout << "Dimes:";
	cout << fdim << endl;
	cout << "Quarters:";
	cout << fqua << endl;
	cout << "Rolled:";
	cout << roll << endl;
	cout << "Cash on hand with rolled coins" << precash << endl;
	cout << "Cash on hand w/o  rolled coins" << precashsroll << endl;

	tone = fone - sone;
	tfiv = ffiv - sfiv;
	tten = ften - sten;
	ttwe = ftwe - stwe;
	tfif = ffif - sfif;
	thun = fhun - shun;
	tpen = fpen - spen;
	tnic = fnic - snic;
	tdim = fdim - sdim;
	tqua = fqua - squa;

	cout << "\t\t\tPOST-TIPS" << endl;
	cout << "Ones:";
	cout << tone << endl;
	cout << "Fives:";
	cout << tfiv << endl;
	cout << "Tens:";
	cout << tten << endl;
	cout << "Twenties:";
	cout << ttwe << endl;
	cout << "Fifties:";
	cout << tfif << endl;
	cout << "Hundreds:";
	cout << thun << endl;
	cout << "Pennies:";
	cout << tpen << endl;
	cout << "Nickels:";
	cout << tnic << endl;
	cout << "Dimes:";
	cout << tdim << endl;
	cout << "Quarters:";
	cout << tqua << endl;
	cout << "Rolled:";
	cout << roll << endl;
	cout << "Cash on hand post tips:" << precash - cctips << endl;
	cout << "Deposit: " << deposit; 
	cout << "\n\n";
	cout << "Total cash in register:" << registertotal << endl;
	cout << "Total credit card tips:" << cctips << endl;
	cout << "Total rolled coin value:" << roll << endl;
	cout << "Deposit: " <<deposit; 
	cout << "\n\n"; 

	cout << "Type 100 to exit program." << endl;
	do{
		cin >> response3; 
	} while (response3 != 100);

	return 0; 
}
Topic archived. No new replies allowed.