this program is supposed to calculate the salary of four types of employees. what is wrong? i have to use the switch structure and it doesnt seems to work. please keep in mind that im only allowed to use the variables and structures used here...its a newbie assignment. thanks in advance.








#include <stdio.h>

int main()
{

float weeklysale, salary1, salary2, salary3, salary4, rate;
int id, paycode, hours, itemsproduced;

printf( "\nEnter employee's ID number (-1 to end): ");
scanf( "%d", &id );

if ( id > 99 ) {
printf ("Wrong ID Number. Please enter a new one (2 digits max.): ");
scanf( "%d", &id );
}

while ( id != -1 ) {
printf( "\nSelect a Paycode:\n1 is for managers\n2 is for commission workers\n" );
printf( "3 is for hourly workers\n4 is for pieceworkers\n\n" );
printf( "Enter chosen Paycode: ");
scanf( "%d", &paycode );


while ( paycode > 0 && paycode < 5 ) {

switch ( paycode ) {

case '1':
paycode = 1;
break;

case '2':
paycode = 2;
break;

case '3':
paycode = 3;
break;

case '4':
paycode = 4;
break;

case '\n': case' ':
break;

default:
printf( "Incorrect Paycode number entered. " );
printf( "Enter new Paycode number:\n" );
break;

}
}


if ( paycode == 1 )
salary1 = 2500.00;
printf( "Salary is $%.2f\n\n\n", salary1 );

if ( paycode == 2 ){
printf( "Enter # of hours worked: " );
scanf( "%d", &hours );

printf( "Enter hourly rate of the worker ($00.00): " );
scanf( "%f", &rate );

if ( hours <= 40 )
salary2 = hours * rate;

if ( hours > 40 )
salary2 = ( float ) (hours - 40) * (1.50 * rate) + (40 * rate);

printf( "Salary is $%.2f\n\n\n", salary2 );
}
if ( paycode == 3 ) {
printf( "Enter gross weekly sales of the worker ($00.O0): ");
scanf( "%f", &weeklysale );

salary3 = 250.00 + ( 6.5 * weeklysale ) / 100;
printf( "Salary is $%.2f\n\n\n", salary3 );
}
if ( paycode == 4 ) {
printf( "Enter # of items produced by the worker: ");
scanf( "%d", &itemsproduced );

printf( "Enter hourly rate of the worker ($00.00): " );
scanf( "%f", &rate );

salary4 = itemsproduced * rate;
printf( "Salary is $%.2f\n\n\n", salary4 );
}

}
return 0;
}