Thank you for all the help so far. Any ideas on this?

This is what I have to do:

In most companies the amount of vacation you receive depends on the number of years you've been with the company. Create a c++ program that will allow the user to enter the number of years and you output the weeks of vacation according to the following:

0 years, 0 weeks vacation

1-5 years, 1 weeks vacation

6-10 years, 2 weeks vacation

11+ years, 3 weeks vacation

Prompt the user if they would like to enter another employee. Also personalize your program by naming your company!

For some reason, the code that I have created is NOT working correctly, and I have tried changing this and changing that with still no success. Here is my 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
#include <iostream>
using namespace std;

int main( )
{
	int years;


	bool tryAgain = true;

	while ( tryAgain == true )
	{
		cout << "How many years have you been with us?\n";
		cin >> years;
{
     if (years == 0)
		{
			cout << "Sorry, no vacation days yet available";

		}
		else if (years >= 5 )
		{
        cout << "Congratulations, you have 1 week Vacation!";
        }
        
        		}
		if (years <5 >10 )
		{
        cout << "Congratulations, you have 2 week Vacation!\n";
        }
        
        		}
	do while (years <11 ==100 )
		{
        cout << "Congratulations, you have 3 week Vacation!\n";
        }

while
		cout << "Would another employee like to enter their data? <y/n> : ";
		cin >> choice;
	   

		if ( choice == 'n' || choice == 'N' )
		{
			tryAgain = false;
		}
	}
		return 0;

}


Can someone PLEASE explain to me where I am goofing up at? I know it is probably something small, but I can NOT figure it out!.

These are all the erros I am getting:

C:\Documents and Settings\Kris_2\Desktop\PTC\Summer 2013\CPT 232\Meeting calculator.cpp In function `int main()':

39 C:\Documents and Settings\Kris_2\Desktop\PTC\Summer 2013\CPT 232\Meeting calculator.cpp expected `(' before "cout"

39 C:\Documents and Settings\Kris_2\Desktop\PTC\Summer 2013\CPT 232\Meeting calculator.cpp expected `)' before ';' token

40 C:\Documents and Settings\Kris_2\Desktop\PTC\Summer 2013\CPT 232\Meeting calculator.cpp `choice' undeclared (first use this function)

48 C:\Documents and Settings\Kris_2\Desktop\PTC\Summer 2013\CPT 232\Meeting calculator.cpp expected unqualified-id before "return"

48 C:\Documents and Settings\Kris_2\Desktop\PTC\Summer 2013\CPT 232\Meeting calculator.cpp expected `,' or `;' before "return"

50 C:\Documents and Settings\Kris_2\Desktop\PTC\Summer 2013\CPT 232\Meeting calculator.cpp expected declaration before '}' token

Can someone PLEASE help me straighten out my code?

Thank you!
line 38: while. While what? It is incoplete statement.
There are a fair few syntax errors going on here.

Syntax for a while loop:
1
2
3
4
while( condition )
{
   // Do stuff
}


Syntax fora do-while loop:
1
2
3
4
do
{
   // Do stuff
} while( condition );


Also, check how you're doing some of your if statements. You're mixing a lot of comparative operations in there.

Finally, make sure all of your braces match up.
Hi dragonscrapper;
i modifeid your code since it has alot of syntax and logical errors especially on
if & do while statements

Try this new modified code and it will run correctly ( i have tested it myself )
if it didn't " while it will runfor sure " let me know;
so here is how your code should be ::

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

int main( )
{
	int years;
	char choice;

	bool tryAgain = true;

	while ( tryAgain )
	{
		cout << "How many years have you been with us?\n";
		cin >> years;

		if (years == 0)
		{
			cout << "Sorry, no vacation days yet available\n";
			break;

		}
		else if (years <= 5 )
		{
			cout << "Congratulations, you have 1 week Vacation!\n";
			break;
                              }
		else if (years > 5 && years < 11 )
		{
		 cout << "Congratulations, you have 2 week Vacation!\n";
			break;
                               }
		else if ( years >= 11 )
		{
			cout << "Congratulations, you have 3 week Vacation!\n";
			break;
		}
        }

	do
	{
		cout << "Would another employee like to enter their data? <y/n> : ";
		cin >> choice;
		if ( choice == 'y' || choice == 'Y' )
		{
			cout << "\n\n\n\n\n";
			main();
		}
		else
			break;
	}
	while ( tryAgain );

	return 0;
}


Mark it as Solved !, Please.

Good Luck, Zaki
Last edited on
Topic archived. No new replies allowed.