Can someone tell me what's wrong with my prgoram :(

#include <iostream>
#include <iomanip>

using namespace std;

int main()
{
int account_number;
int minutes;
char service;
double amount_due;
double day_min;
double night_min;
double regular;
double premium;

cout << fixed << showpoint;
cout << setprecision(2);

cout << "Please enter account number." << endl;
cin >> account_number;

cout << "Please enter account type.(R or r for regular service, P or p for premium service.)" << endl;
cin >> service;

switch(service)
{
case 'R':
case 'r':
cout << "Enter amount of minutes used." << endl;
cin >> minutes;

while(minutes <= 50)
{
amount_due=10.00;
cout << "Amount due:$" << amount_due << endl;
}

while(minutes > 50)
{
amount_due= ((minutes-50)*.20+10.00);
cout << "Amount due:$" << amount_due << endl;
}

break;

case 'P':
case 'p':
{
cout << "How many minutes were used during the day?";
cin >> day_min;

cout << "How many minutes were used during the night?";
cin >> night_min;

while(day_min <= 75)
{
amount_due=25.00;
cout << "Amount due:$" << amount_due << endl;
}

while(day_min > 75)
{
amount_due = ((day_min - 75) * .10)+ 25.00;
cout << "Amount due:$" << amount_due << endl;
}

while(night_min <= 100)
{
amount_due=25.00;
cout << "Amount due:$" << amount_due << endl;
}

while(night_min > 100)
{
amount_due=amount_due = ((night_min - 100) * .05)+ 25.00;
cout << "Amount due:$" << amount_due << endl;
}

break;
}
default:
cout << "Invalid customer type." << endl;
}


cin.get();
cin.get();

return 0;
}
You can't just give us a big code(even with no code tags!!) and simply ask us "what's wrong?"! What happens when you compile it? Does it even compile? If it doesn't, does the compiler say where the problem is? If it compiles, what happens when you run it? Does it simply crash at the beggining? Does it crash after some input? Does it crash after some output? Does it give any output? Does it give the right output? Does it get stuck in an infinite loop? Does it make your computer explode?
Are you doing math without the math include #include <math.h>?
Your while loops never change the value that controls how long the while loops will run for, so they run forever.
hi buddy,i used turbo c++3.0 to compile your code and it shows 9 error and 1 warning. But as soon as i specified the extension of the file iostream and iomanip in include command it reduced to only 3 errors.I just added '.h' to that command and changed them to #include<iostream.h> and #include<iomanip.h>. I'll bug those error too,as soon as possible.
But as soon as i specified the extension of the file iostream

iostream has no extension. Maybe you should stop using a compiler that was written before the dark ages.
@Athar -
will u please tell me which compiler u r using....
where will i get this compiler....
I'm actually studying Turbo c++ 3.0 as one of my subject at school....
This article contains a list of options: http://www.cplusplus.com/articles/36vU7k9E/

Turbo C++ 3.0 was released in 1991. In 1991, C++ had no formal (ISO) definition; it was strung together based on the clues provided by Stroustrup. In the 21 years that have passed since then, C++ has gone through three formal versions (C++ 98, 03 and 11). If you learn C++ using a 21 year old compiler, you will miss out on two decades of language development and will not be learning what the rest of the world (including potential employers) consider to be C++.
thnx for this suggestion.....lets debug the above program
Last edited on
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
#include <iostream>
#include <iomanip>
#include <maths.h>

using namespace std;

int main()
{
	int account_number;
	int minutes;
	char service;
	double amount_due;
	double day_min;
	double night_min;
	double regular;
	double premium;

	cout << fixed << showpoint;
	cout << setprecision(2);

	cout << "Please enter account number." << endl;
	cin >> account_number;

	cout << "Please enter account type.(R or r for regular service, P or p for premium service.)" << endl;
	cin >> service;

	switch(service)
	{
		case 'R':
		case 'r':
							cout << "Enter amount of minutes used." << endl;
							cin >> minutes;

								if(minutes <= 50)
								{
								amount_due=10.00;
								cout << "Amount due:$" << amount_due << endl;
								}

								if(minutes > 50)
								{
								amount_due= ((minutes-50)*.20+10.00);
								cout << "Amount due:$" << amount_due << endl;
								}

								break;

case 'P':
case 'p':

								cout << "How many minutes were used during the day?";
								cin >> day_min;

								cout << "How many minutes were used during the night?";
								cin >> night_min;

								if(day_min <= 75)
								{
								amount_due=25.00;
								cout << "Amount due:$" << amount_due << endl;
								}

								if(day_min > 75)
								{
								amount_due = ((day_min - 75) * .10)+ 25.00;
								cout << "Amount due:$" << amount_due << endl;
								}

								if(night_min <= 100)
								{
								amount_due=25.00;
								cout << "Amount due:$" << amount_due << endl;
								}

								if(night_min > 100)
								{
								amount_due=amount_due = ((night_min - 100) * .05)+ 25.00;
								cout << "Amount due:$" << amount_due << endl;
								}

								break;
		
default:
cout << "Invalid customer type." << endl;
}


cin.get();


return 0;
} 


Hope this works .
Last edited on
except not maths.h, math.h
Topic archived. No new replies allowed.