console program requesting criticism

Intro:
So new to c++ (obviously). I made a console program for my course and already turned it in, but want to know what I could have done better and what I didn't do right.

Problem:
Using visual studio it works in debug but when compiled in release if you type in a letter in for the total it closes (or crashes) the program instead of displaying that there was an error and asking you to type it in again.

What it does:
What is does is ask for name (i like to say hello), month (1-12), year (1000+), total amount of money in register that day (0+), and then spits out all the information including taxes.

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
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
#include <iostream>
#include <string>
#include <iomanip>
#include <windows.h>

using namespace std;
int main ()
{
	// Personal Additions
	SetConsoleTitle( TEXT("Monthly Sales Tax by me -_-"));
	string name;
	string Line1 = "\n\n===========================================================\n\n";
	string Line2 = "\n===========================================================";

	// Months Array
	string months[]={"January","February","March","April","May","June","July","August","September","October","November","December"};
	double total, sales, sstax, sstaxv, cstax, cstaxv, ttax;
	int m, year;
	

	// NAME
	cout << "What is your Name? ";
	getline(cin, name);
	cout << "\nHello " << name << "!\n";
	Sleep(1000);

	// INTRO
	cout << Line1;
	cout << "Please answer the following questions...";
	cout << Line1;

	// MONTH
	cout << "\n - Month (1-12)? ";
	cin >> m;
	while(m < 1 || m > 12)
	{
		cout << Line2;
		cout << "\nError Id10T :]";
		cin.clear();
		while(cin.get() != '\n');
		cout << "\n\n - What Is The Month (ex 1-12)? ";
		cin >> m;
	}

	// YEAR
	cout << Line2;
	cout << "\n - Year (ex 2013)? ";
	cin >> year;
	while(year < 1000)
	{
		cout << Line2;
		cout << "\nError Id10T :]";
		cin.clear();
		while(cin.get() != '\n');
		cout << "\n\n - What Is The Year (ex 2013)? ";
		cin >> year;
	}

	// TOTAL AMOUNT
	cout << Line2;
	cout << "\n - Total Amount (ex 10.01)? ";
	cin >> total;
	while(total < 0)
	{
		cout << Line2;
		cout << "\nError Id10T :]";
		cin.clear();
		while(cin.get() != '\n');
		cout << "\n\n - What Is The Total Amount (ex 10.01)? ";
		cin >> total;
	}

	// tax variables
	sstaxv = .04, cstaxv = .02;

	//formulas
	sales = total / (1 + sstaxv + cstaxv);
	sstax = sales * sstaxv;
	cstax = sales * cstaxv;
	ttax = sstax + cstax;

	cout << fixed << showpoint << setprecision(2);
	//RESULT
	cout << string(50, '\n');
	cout << left << setw(7) << "Month: " << setw(13) << months[m-1];
	cout << setw(5) << "Year: " << setw(5) << year << endl;
	cout << Line2 << endl;
	cout << left << setw(30) << "Total Collected:";
	cout << "$" << right << setw(8) << total << endl;
	cout << left << setw(30) << "Sales:";
	cout << "$" << right << setw(8) << sales << endl;
	cout << left << setw(30) << "County Sales Tax:";
	cout << "$" << right << setw(8) << cstax << endl;
	cout << left << setw(30) << "State Sales Tax:";
	cout << "$" << right << setw(8) << sstax << endl;
	cout << left << setw(30) << "Total Sales Tax:";
	cout << "$" << right << setw(8) << ttax << endl;
	cout << "\nPress enter to exit...";
	cin.ignore();
	cin.get();
	cout << string(50, '\n');
	cout << "Have a nice day " << name << "!!!";
	Sleep(5000);
	exit;
}


Result:
What is your Name? bob

Hello bob!


===========================================================

Please answer the following questions...

===========================================================


 - Month (1-12)? 10

===========================================================
 - Year (ex 2013)? z

===========================================================
Error Id10T :]

 - What Is The Year (ex 2013)? 2010

===========================================================
 - Total Amount (ex 10.01)? 5000

Month: October      Year: 2010

===========================================================
Total Collected:              $ 5000.00
Sales:                        $ 4716.98
County Sales Tax:             $   94.34
State Sales Tax:              $  188.68
Total Sales Tax:              $  283.02

Press enter to exit...



Thanks for criticism in advance :)!
try
while(total <= 0)

what I didn't do right.

your smart ass "Error Id10T :]" msg isn't going to make you many friends.

Last edited on
Topic archived. No new replies allowed.