Answer to Question #45016 in C for Bone

Question #45016
1. define a structure employee with name, category , salary, tax as a member. read the name category and salary of employee and calculate the tax as below

categories
A 10% OF SALARY
B 15% OF SALARY
C 20% OF SALARY
OTHERS 30% OF SALARY


2.firstly write a program to accept the number of telephone calls made by a customer and the print out the rate in cents.
1
Expert's answer
2014-08-21T03:25:24-0400
#include <stdio.h>
#include <stdlib.h>
#include <string.h>//include this header for functions strcmp and strncmp

struct employee{
char nameCategory[15];
double salary;
double tax;
};
//main function
int main(){
//struct employee
struct employee _employee;
//prompt user to enter name category
printf("Enter name category: ");
//read name category
scanf("%s",&_employee.nameCategory);
//prompt user to enter salary
printf("Enter salary: ");
//read salary
scanf("%lf",&_employee.salary);
//calculate A 10% OF SALARY
if(strcmp(_employee.nameCategory,"A")==0){
_employee.tax=0.1*_employee.salary;
}
//calculate B 15% OF SALARY
else if(strcmp(_employee.nameCategory,"B")==0){
_employee.tax=0.15*_employee.salary;
}
//calculate C 20% OF SALARY
else if(strcmp(_employee.nameCategory,"C")==0){
_employee.tax=0.2*_employee.salary;
}
//calculate OTHERS 30% OF SALARY
else{
_employee.tax=0.3*_employee.salary;
}
//show result
printf("The tax = $ %lf",_employee.tax);
system("pause");
return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS