fix my coding, please

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

int staff_menu(int choice, int item_w, int bil_item, int choice1, double total);
float admin_menu();

void main()
{
	staff_menu;
}

staff_menu()
{
	cout << "\t\t\t\t   STAFF MENU" << endl;
	cout << "\t\t\t********************************" << endl;
	cout << "\t\t\t1. View Staff Schedule" << endl;
	cout << "\t\t\t2. Calculate Total Item Recycled" << endl;
	cout << "\t\t\t3. Print Report" << endl;
	cout << "\t\t\t4. Back" << endl;
	cout << "\t\t\t********************************\n" << endl;

	cout << "->>Please enter your choice" << endl;
	cin >> choice;

	if (choice == 1)
	{
		//jadual staf
		cout << "\nStaff Schedule" << endl;
	}

	else
		if (choice == 2)
	{
		//kira
		cout << "\nCalculate Total Item Recycled" << endl;
		cout << "\nEnter item weight" << endl;
		cout << "\nItem weight = "; cin >> item_w;
		cout << "\nEnter number of item recycled" << endl;
		cout << "\nNumber of item recycled = "; cin >> bil_item;
		total=item_w*bil_item;
		cout << "\nTotal Item Recycled is " << total << " metric tons" << endl;
	}

		else
			if (choice == 3)
			{
				//report
		cout << "\nPrint Report" << endl;
		cout << "Select which report to be print" << endl;
		cout << "1. Staff's monthly payroll " << endl;
		cout << "2. Total item recycled " << endl;
			}

		cin >> choice1;

		if (choice1 == 1)
	{
		cout << "\nStaff's monthly payroll" << endl;

	}
		else

		if (choice1 == 2)
	{
				cout << " Total item recycled " << endl;

	}




	return 0;
}


im trying to staff_menu as function call,
please help, thanks
I think when you have a variable like "choice" that can have more than two values, you should use a switch statement (assuming that your variable is an integer expression.) The code ends up being cleaner, easier to read, and easier to maintain.
1
2
3
4
void main()
{
	staff_menu;
}


That's not how you call a function. You should go back to your textbook and read the correct syntax for calling functions.
Also compare line 4 and line 12.
insert arguments inside ( ) in line 12 listed in fuction prototype in line 4
thanks for replying,
im really a noob programmer here.

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

int staff_menu(int choice, int item_w, int bil_item, int choice1, double total);
float admin_menu();

void main()
{
	staff_menu(int choice, int item_w, int bil_item, int choice1, double total);
}

staff_menu(int choice, int item_w, int bil_item, int choice1, double total)
{
	cout << "\t\t\t\t   STAFF MENU" << endl;
	cout << "\t\t\t********************************" << endl;
	cout << "\t\t\t1. View Staff Schedule" << endl;
	cout << "\t\t\t2. Calculate Total Item Recycled" << endl;
	cout << "\t\t\t3. Print Report" << endl;
	cout << "\t\t\t4. Back" << endl;
	cout << "\t\t\t********************************\n" << endl;

	cout << "->>Please enter your choice" << endl;
	cin >> choice;

	if (choice == 1)
	{
		//jadual staf
		cout << "\nStaff Schedule" << endl;
	}

	else
		if (choice == 2)
	{
		//kira
		cout << "\nCalculate Total Item Recycled" << endl;
		cout << "\nEnter item weight" << endl;
		cout << "\nItem weight = "; cin >> item_w;
		cout << "\nEnter number of item recycled" << endl;
		cout << "\nNumber of item recycled = "; cin >> bil_item;
		total=item_w*bil_item;
		cout << "\nTotal Item Recycled is " << total << " metric tons" << endl;
	}

		else
			if (choice == 3)
			{
				//report
		cout << "\nPrint Report" << endl;
		cout << "Select which report to be print" << endl;
		cout << "1. Staff's monthly payroll " << endl;
		cout << "2. Total item recycled " << endl;
			}

		cin >> choice1;

		if (choice1 == 1)
	{
		cout << "\nStaff's monthly payroll" << endl;

	}
		else

		if (choice1 == 2)
	{
				cout << " Total item recycled " << endl;

	}




	return 0;
}


error:
1>c:\users\nasr\documents\visual studio 2010\projects\xv2\xv2\lll.cpp(9): error C2144: syntax error : 'int' should be preceded by ')'
1>c:\users\nasr\documents\visual studio 2010\projects\xv2\xv2\lll.cpp(9): error C2660: 'staff_menu' : function does not take 0 arguments
1>c:\users\nasr\documents\visual studio 2010\projects\xv2\xv2\lll.cpp(9): error C2059: syntax error : ')'
1>c:\users\nasr\documents\visual studio 2010\projects\xv2\xv2\lll.cpp(13): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
A prototype tells the compiler what to expect when you define a function. You prototype it with a return value of an integer (int) then when you define it you don't give it any return type. Then you are trying to return 0 (int). Also line 9 you are calling it wrong. What you are doing is essentially this:

1
2
int a = 1;
cout << int a << endl;


Please read up on functions:
http://www.cplusplus.com/doc/tutorial/functions/
http://www.cplusplus.com/doc/tutorial/functions2/
http://www.learncpp.com/ --check out chapter 7 (functions)
http://www.learncpp.com/cpp-tutorial/71-function-parameters-and-arguments/ --first part of chapter 7
http://www.learncpp.com/cpp-tutorial/714-ellipses-and-why-to-avoid-them/ --last part of chapter 7
oh,
one more thing,

the arguments you are passing to the function staff_menu in main does not exist, hence rewrite the main part like this::

1
2
3
4
5
6
7
void main()
{
int choice, item_w, bil_item, int choice1;
 double total;
cin>>choice>>item_w<<bil_item<<choice1<<total;
	staff_menu(choice, item_w,  bil_item,  choice1,  total);
}

staff_menu(int choice, int item_w, int bil_item, int choice1, double total);

This still isn't the correct syntax for calling a function. Textbook, etc.
Topic archived. No new replies allowed.