updname() cant execute

i have problems with executing my updname();, can u guys help me check errors? its already running but updname() is malfunctioning... thanks!

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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
#include <stdio.h>
#include <conio.h>
#include <iostream.h>
#include <string.h>

#define MAX 50
char name[MAX][30];
char exper[MAX][20];
int idno[MAX];
char jlvl[MAX];
float mnthsr[MAX];
double annusr[MAX];
int cons[MAX];


int getInfo()
{
	int x;
	char yesno1;
	clrscr();
	x=1;
	restart1:
	if(x<=50)
		{
		if (cons[x]!=0)
			{
			x++;
			cons[x]=1;
			}
		else
			{
			cout << "\n\nFill up the Information needed to proceed:\n\nName:\t";
			gets(name[x]);
			cout << "\nExpertise:\t";
			gets(exper[x]);
			cout << "\nIdentification Number:\t";
			scanf("%d",&idno[x]);
			cout << "\nJob level: (Please select from 'A', 'B', 'C', 'D')\t";
			jlvl[x] = getch();
			cout << "\nMonthly Salary Rate:";
			scanf("%f",&mnthsr[x]);
			cout << "\nYour Annual Salary Rate is:\t";

			switch(jlvl[x])
				{
				case'a':{
					annusr[x]=(mnthsr[x])*12;
					}
				case'b':{
					annusr[x]=(mnthsr[x])*13;
					}
				case'c':{
					annusr[x]=(mnthsr[x])*14;
				case'd':{
					annusr[x]=(mnthsr[x])*15;
					}
				default:
					{
					cout << " ";
					}
				}

			printf("%.2lf",annusr[x]);
			}
		cout << "\n\nDo you want to do it again? y/n:\t";
		yesno1 = getch();
		switch(yesno1)
			{
			case'y':
				{
				goto restart1;
				}
			default:
				{
				cout << "\nPress any key to continue:";
				}
			}
		getch();
		}
		}
	return 0;
}


updidno()
{
	int y;
	int seaidno;
	clrscr();
	cout << "\n\n\t\tYou have selected ID NUMBER:";
	cout << "\n\tPlease enter the ID NUMBER of the account you wish to update:";
	scanf("%d",&seaidno);
	cout << "\n\n\tSEARCHING...";
	for(y=0;y<50;y++)
		{
		if(seaidno==idno[y])
			{
			cout << "\nName:\t" << name[y];
			cout << "\nExpertise:\t" << exper[y];
			cout << "\nID Number:\t" << idno[y];
			cout << "\nJob Level:\t" << jlvl[y];
			printf("\nMonthly Salary Rate:\t%.2f",mnthsr[y]);
			printf("\nAnnual Salary Rate:\t%.2lf",annusr[y]);

			}
		else
			cout << "";
		}
		getch();
		return 0;
}

updname()
{
	int y;
	clrscr();
	char seaname[MAX];
	cout << "\n\n\t\tYou have selected NAME:";
	cout << "\n\tPlease enter the NAME of the account you wish to update:";
	cgets(seaname);
	cout << "\n\n\tSEARCHING...";
	for(y=0;y<50;y++)
		{
		if(strcmpi(seaname,name[y])==0)
			{
			cout << "\nName:\t" << name[y];
			cout << "\nExpertise:\t" << exper[y];
			cout << "\nID Number:\t" << idno[y];
			cout << "\nJob Level:\t" << jlvl[y];
			cout << "\nMonthly Rate:\t" << mnthsr[y];
			cout << "\nAnnual Rate:\t" << annusr[y];
			}
		else
			cout << "";
		}
		getch();
		return 0;
}

void updInfo()
{
	int updchoice;
	updres:
	clrscr();
	cout << "\n\n\t\t-Update Consultant Info-";
	cout << "\n\n\tPlease select for the search methods:";
	cout << "\n\t[1] NAME";
	cout << "\n\t[2] ID NUMBER";
	cout << "\n\t[3] EXIT";
	cout << "\n\nYour Choice:\t";
	scanf("%d",&updchoice);
	switch(updchoice)
		{
		case 1:{
			updname();
			goto updres;
			}
		case 2:{
			updidno();
			goto updres;
			}
		default:
			{
			cout << "Invalid Selection!";
			}
		}
}


int main(int menures)
{
	resmenu:
	clrscr();
	cout << "\n\n\n\n\n\t" << "[1]\tADD NEW CONSULTANT";
	cout << "\n\t" << "[2]\tUPDATE CONSULTANT RECORD";
	cout << "\n\t" << "[3]\tDISPLAY CONSULTANT LIST";
	cout << "\n\t" << "[4]\tEXIT";
	cout << "\n\t" << "\n\nYour Choice:\t";

	cin >> menures;
	switch(menures)
		{
		case 1:
			{
			getInfo();
			goto resmenu;
			}
		case 2:
			{
			updInfo();
			goto resmenu;
			}
		case 3: {
			updname();
			goto resmenu;
			}
		case 4:
			{
			goto exit;
			}
		}
	exit:
	return (menures);
}


thanks!
It would help us a great deal if you gave us some background on what you are attempting to accomplish with your program as well as why you think that the function in question is malfunctioning? I personally don't have time to study the program and debug it for you without having some information on what type of problem I am looking for.

Take a look at this.
http://cplusplus.com/forum/beginner/1/
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
Prompt the user for the number of consultants for each consultant, prompt the user to enter values for each of the ff:

1. NAME (30 characters)
2.EXPERTISE (20 characters)
3. IDENTIFICATION NUMBER (integer)
4.JOB LEVEL (possible values allowed are 'A', 'B', 'C', 'D')
5. MONTHLY SALARY RATE (float with 2 decimal places)
6. ANNUAL SALARY RATE (double with 2 decimal places, computation depends on the job level)

for job level 'A' 12-month pay
for job level 'B' 13-month pay
for job level 'C' 14-month pay
for job level 'D' 15-month pay

Each element should be stored in arrays.
Assume a maximum of 50 consultants for this program. Display the data in table format after the user entered the last consultant.

SAMPLE MENU:

[1] ADD NEW CONSULTANT
[2] UPDATE CONSULTANT RECORD
[3] DISPLAY CONSULTANT LIST
[4] QUIT


For the 2nd choice menu is:
1. NAME
2. ID NUMBER

If the input is 1, prompt the user for the consultant name to be updated. If choice 2, prompt user for ID no. of the consultant.

If the consultant is not yet in the list, then inform the user that such consultant cannot be found in the list. Otherwise, display the complete record of the matching consultant in the list. then for each field, ask the user if he/she wants to update that field. If yes then prompt the user for the new value of the field. Control goes back to the main menu.

For the third choice, display out the data in table format as below:

NAME EXPERTISE ID NO. JOB LEVEL MONTHLYRATE

1 MANUEL DIAZ COMPT SPECIALIST 476 D 845.56

2 ELENA MARQUEZ SOUND EDITOR 596 b 1745.23



there :)
Last edited on
Topic archived. No new replies allowed.