HELP ME WITH THIS PLEASE, MY PROJECT! '::main' must return 'int' error

#include<iostream>
#include<cmath>
using namespace std;

void main()
{

int code, qty, cash;
double tDue, change;


cout<<"\t\t\tWelcome to DuaNetopia!"<<endl<<endl;
cout<<"Hour Codes and Price"<<endl<<endl;
cout<<"1 1 Hour Php25"<<endl;
cout<<"2 2 Hours Php50"<<endl;
cout<<"3 3 Hours Php75"<<endl;
cout<<"4 4 Hours Php100"<<endl;
cout<<"5 5 Hours Php120 Promo!"<<endl;
cout<<"6 Play All You Can Php1000"<<endl<<endl;

cout<<"Enter Code: ";
cin>>code;


switch (code)
{
case 1: cout<<"1 Hour Php25";
cout<<"How Many?: ";
cin>>qty;

{
if (qty<0)
cout<<"Invalid Quantity Number"<<endl;
else
tDue=25*qty;
cout<<"Total Due: "<<tDue<<endl;
}

cout<<"Cash: ";
cin>>cash;

change=cash-tDue;

{
if (cash<0 || cash<tDue)
cout<<"Invalid Cash"<<endl;
else
cout<<"Change: "<<change<<endl<<endl;
}


break;

case 2: cout<<" 2 Hours Php50"<<endl;
cout<<"How Many?: ";
cin>>qty;

{
if (qty<0)
cout<<"Invalid Quantity Number"<<endl;
else
tDue=50*qty;
cout<<"Total Due: "<<tDue<<endl;
}

cout<<"Cash: ";
cin>>cash;

change=cash-tDue;

{
if (cash<0 || cash<tDue)
cout<<"Invalid Cash"<<endl;
else
cout<<"Change: "<<change<<endl<<endl;
}

break;

case 3: cout<<"3 Hours Php75";
cout<<" How Many?: ";
cin>>qty;

{
if (qty<0)
cout<<"Invalid Quantity Number"<<endl;
else
tDue=75*qty;
cout<<"Total Due: "<<tDue<<endl;
}

cout<<"Cash: ";
cin>>cash;

change=cash-tDue;

{
if (cash<0 || cash<tDue)
cout<<"Invalid Cash"<<endl;
else
cout<<"Change: "<<change<<endl<<endl;
}

break;

case 4: cout<<"4 Hours Php100";
cout<<" How Many?: ";
cin>>qty;

{
if (qty<0)
cout<<"Invalid Quantity Number"<<endl;
else
tDue=100*qty;
cout<<"Total Due: "<<tDue<<endl;
}

cout<<"Cash: ";
cin>>cash;

change=cash-tDue;

{
if (cash<0 || cash<tDue)
cout<<"Invalid Cash"<<endl;
else
cout<<"Change: "<<change<<endl<<endl;
}

break;

case 5: cout<<"5 Hours Php120 Promo!";
cout<<" How Many?: ";
cin>>qty;

{
if (qty<0)
cout<<"Invalid Quantity Number"<<endl;
else
tDue=120*qty;
cout<<"Total Due: "<<tDue<<endl;
}

cout<<"Cash: ";
cin>>cash;

change=cash-tDue;

{
if (cash<0 || cash<tDue)
cout<<"Invalid Cash"<<endl;
else
cout<<"Change: "<<change<<endl<<endl;
}

break;

case 6: cout<<"Play All You Can Php1000";

tDue=1000*qty;
cout<<"Total Due: "<<tDue<<endl;
}

cout<<"Cash: ";
cin>>cash;

change=cash-tDue;

{
if (cash<0 || cash<tDue)
cout<<"Invalid Cash"<<endl;
else
cout<<"Change: "<<change<<endl<<endl;
}

break;

default: cout<<"Invalid Hour Code"<<endl<<endl;

}

cout<<"=============== CHANGE BREAKDOWN ==============="<<endl;
You have two major problems:
1. You are using void main(). You should use int main() and then use return 0; at the end of the main function.
2. Your {s and }s are mismatched. I can tell because you have breaks and default: outside of the switch statement. Proper formatting will help you with this. Since you didn't use code tags, I can't tell what your indenting looks like. You also have a cout<< in the global scope, meaning that it isn't in any function.

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
#include<iostream>
#include<cmath>
using namespace std;

int main() //main() should be int, not void
{
	int code, qty, cash;
	double tDue, change;

	cout<<"\t\t\tWelcome to DuaNetopia!"<<endl<<endl;
	cout<<"Hour Codes and Price"<<endl<<endl;
	cout<<"1	 1 Hour	 Php25"<<endl;
	cout<<"2	 2 Hours Php50"<<endl;
	cout<<"3	 3 Hours Php75"<<endl;
	cout<<"4	 4 Hours Php100"<<endl;
	cout<<"5	 5 Hours Php120 Promo!"<<endl;
	cout<<"6	 Play All You Can	 Php1000"<<endl<<endl;

	cout<<"Enter Code: ";
	cin>>code;

	switch (code)
	{
	case 1: cout<<"1 Hour Php25";
		cout<<"How Many?: ";
		cin>>qty;

		{ // Why are you using these?
			if (qty<0)
				cout<<"Invalid Quantity Number"<<endl;
			else
				tDue=25*qty;
			cout<<"Total Due: "<<tDue<<endl;
		}

		cout<<"Cash: ";
		cin>>cash;

		change=cash-tDue;

		{
			if (cash<0 || cash<tDue)
				cout<<"Invalid Cash"<<endl;
			else
				cout<<"Change: "<<change<<endl<<endl;
		}

		break;

	case 2: cout<<" 2 Hours Php50"<<endl;
		cout<<"How Many?: ";
		cin>>qty;

		{
			if (qty<0)
				cout<<"Invalid Quantity Number"<<endl;
			else
				tDue=50*qty;
			cout<<"Total Due: "<<tDue<<endl;
		}

		cout<<"Cash: ";
		cin>>cash;

		change=cash-tDue;

		{
			if (cash<0 || cash<tDue)
				cout<<"Invalid Cash"<<endl;
			else
				cout<<"Change: "<<change<<endl<<endl;
		}	

		break;

	case 3: cout<<"3 Hours Php75";
		cout<<" How Many?: ";
		cin>>qty;

		{
			if (qty<0)
				cout<<"Invalid Quantity Number"<<endl;
			else
				tDue=75*qty;
			cout<<"Total Due: "<<tDue<<endl;
		}

		cout<<"Cash: ";
		cin>>cash;

		change=cash-tDue;

		{
			if (cash<0 || cash<tDue)
				cout<<"Invalid Cash"<<endl;
			else
				cout<<"Change: "<<change<<endl<<endl;
		}	

		break;

	case 4: cout<<"4 Hours Php100";
		cout<<" How Many?: ";
		cin>>qty;

		{
			if (qty<0)
				cout<<"Invalid Quantity Number"<<endl;
			else
				tDue=100*qty;
			cout<<"Total Due: "<<tDue<<endl;
		}

		cout<<"Cash: ";
		cin>>cash;

		change=cash-tDue;

		{
			if (cash<0 || cash<tDue)
				cout<<"Invalid Cash"<<endl;
			else
				cout<<"Change: "<<change<<endl<<endl;
		}	

		break;

	case 5: cout<<"5 Hours Php120 Promo!";
		cout<<" How Many?: ";
		cin>>qty;

		{
			if (qty<0)
				cout<<"Invalid Quantity Number"<<endl;
			else
				tDue=120*qty;
			cout<<"Total Due: "<<tDue<<endl;
		}

		cout<<"Cash: ";
		cin>>cash;

		change=cash-tDue;

		{
			if (cash<0 || cash<tDue)
				cout<<"Invalid Cash"<<endl;
			else
				cout<<"Change: "<<change<<endl<<endl;
		}	

		break;

	case 6: cout<<"Play All You Can	 Php1000";

		tDue=1000*qty;
		cout<<"Total Due: "<<tDue<<endl;
	} // This ends the switch, but you have default later

	cout<<"Cash: ";
	cin>>cash;

	change=cash-tDue;

	{
		if (cash<0 || cash<tDue)
			cout<<"Invalid Cash"<<endl;
		else
			cout<<"Change: "<<change<<endl<<endl;
	}

	break; // You're not in the swtich anymore, 

	default: cout<<"Invalid Hour Code"<<endl<<endl; // You're not in the switch anymore

	//You're at the end of main() here, you must return a value: i.e. 
	//return 0;
}

//cout<<"=============== CHANGE BREAKDOWN ==============="<<endl; This isn't in your main function, that is ended 
Topic archived. No new replies allowed.