有人能告诉我为什么这段代码不计算总工资和其他代码吗?这段代码中存在一个问题,它不像程序想要的那样计算。有人可以帮我查明错误吗?
#include <stdio.h>
#include <conio.h>
int main()
{
char fname[20];
char lname[20];
char IDnumber[20];
char Position;
float Hoursworked,Grosspay,Tax,Netpay;
printf(" ************iG Company************** \n\n");
printf("Enter the employee's First Name:\n");
scanf("%s", &fname);
printf("Enter the employee's Last Name:\n");
scanf("%s", &lname);
printf("Enter IDnumber:\n");
scanf("%s",&IDnumber);
printf("<1>Manager <2>Supervisor heart>Employee <4>Office Boy/girl \n");
printf("Enter Position:\n");
scanf("%s", &Position);
switch(Position)
{
case '1':
printf("Rate per hour:P150.00 \n");
printf("No. of hours worked:");
scanf("%d", &Hoursworked);
Grosspay = Hoursworked * 150;
printf("Gross: \n", Grosspay);
Tax = Grosspay * 0.1f;
printf("TAX:\n", Tax);
Netpay = Grosspay - Tax;
printf("NET PAY: \n", Netpay);
break;
case '2':
printf("Rate:P100.00 \n");
printf("No. of hours worked:");
scanf("%d", &Hoursworked);
Grosspay = Hoursworked * 100;
printf("Gross:\n", Grosspay);
Tax = Grosspay * 0.1f;
printf("TAX: \n", Tax);
Netpay = Grosspay-Tax;
printf("NET PAY: \n", Netpay);
break;
case '3':
printf("Rate:P70.00 \n");
printf("No. of hours worked:");
scanf("%d", &Hoursworked);
Grosspay = Hoursworked * 70;
printf("Gross: \n", Grosspay);
Tax = Grosspay * 0.1f;
printf("TAX:\n", Tax);
Netpay = Grosspay - Tax;
printf("NET PAY: \n", Netpay);
break;
case '4':
printf("Rate per hour:P50.00 \n");
printf("No. of hours worked:");
scanf("%d", &Hoursworked);
Grosspay = Hoursworked * 50;
printf("Gross:\n", Grosspay);
Tax = Grosspay * 0.1f;
printf("TAX:\n", Tax);
Netpay = Grosspay - Tax;
printf("NET PAY:\n", Netpay);
break;
default:
printf("Invalid");
}
getch();
}