Help with switch statement.

I'm writing a program to switch between four different paycodes. I was initially doing if else statements but I kept getting a c2181 error message. I changed it to a switch statement with 1-4 being different paycodes and -1 to exit. It compiles without error but then asks for the 1-4 paycode and after you enter one of them it just sort of stalls out.
Thanks for any help.

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

#include <iostream>
#include <iomanip>

int main()
{
	int hours;
	int paycode;
	int pieces;
	double payrate;

	std::setprecision( 2 );
	std::fixed;

		std::cout << "Enter paycode (-1 to end): ";
		std::cin >> paycode;

		while (paycode != -1);
		{
			switch ( paycode )
			{

			case 1:
			std::cout << "Manager selected.\nEnter weekly salary: ";
		    std::cin >> payrate;
			std::cout << "Manager's pay is $" << payrate;
			break;
			case 2:
			std::cout << "Hourly Worker selected.\nEnter the hourly salary: ";
		    std::cin >> payrate;
			std::cout << "Enter the total hours worked: ";
			std::cin >> hours;
			
			if ( hours < 40)
				payrate = hours * payrate;
				std::cout << "Hourly worker's pay is $" << payrate;
			if (payrate >=40) 
				payrate = payrate * 40 + ((1.5*payrate)*(hours - 40));
				std::cout << "Hourly worker's pay is $" << payrate;
			
				break;
		
			case 3:
			std::cout << "Commission Worker selected.\nEnter gross weekly sales: ";
		    std::cin >> payrate;
			payrate = 250.00 + (payrate *.092);
			std::cout << "Commission worker's pay is $" << payrate;
			break;
			
			case 4:
			std::cout << "Widget Worker selected.\nEnter number of pieces: ";
			std::cin >> pieces;
			std::cout << "Enter wage per piece: ";
			std::cin >> payrate;
			payrate = pieces * payrate;
			std::cout << "Widget Worker's pay is $" << payrate;
			break;

			default:
				break;
			}
		}
You don't need a semicolon on line 18 while (paycode != -1);
Helpful! Thanks! It's still doing goofy stuff but has stopped stalling at least. So I'm on to the next round of tinkering.
Topic archived. No new replies allowed.