Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <ctype.h>
- #include <unistd.h>
- #include <string.h>
- int main()
- { char fullname[100], forename[30],surname[50], code;
- int id;
- float gross, tax, net;
- //the use of toupper is for the use of both upper and lowercase entered from user
- printf("This program will calculate your tax reduction and display employee information. \n \n");
- sleep(1);
- do{
- printf("Please enter tax code: \nS for self-employed \nC for company employed \n");//the printf is requesting from the user
- scanf("%c", &code);//had to place before all
- code=toupper(code);
- if(code!='S' && code!='C')
- printf("invalid input \n\nPlease enter again\n\n");
- }while(code!='S' && code!='C');
- printf("Please enter Employee forename \n");
- scanf(" %s", forename); //scan string such as multiple inputs rather than just a single character
- printf("Please enter Employee surname \n");
- scanf(" %s", surname); //scan string such as multiple inputs rather than just a single character
- printf("Employee name %s %s \n\n", forename, surname);
- printf("Please enter Employee ID \n");
- scanf("%d", &id); //decimal numbers
- printf("Please enter Employee gross wage \n");
- scanf("%f", &gross); //float
- if(code=='S' && gross>27000){
- net=gross-(gross*0.42);
- }else if(code=='S' && gross>=20000){
- net=gross-(gross*0.23);
- }else if(code=='S' && gross<20000){
- gross=net-(gross*0.2);
- }else if(code=='C'&& gross>29000){
- gross=net-(gross*0.4);
- }else if(code=='C' && gross>=18000){
- gross=net-(gross*0.2);
- }else if(code ='C' && gross<18000){
- gross=net-(gross*0.1);
- }
- tax=gross-net;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement