Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<conio.h>
- #include<ctype.h> //function variable=toupper(variable)
- #include<stdlib.h> //function fflush(stdin) to make sure input overflow does not happen
- void main()
- {
- int hours;
- float rate, benefits, gross, tax;
- char plan, control;
- printf("Please enter the number of hours worked: ");
- scanf_s("%d", &hours);
- printf("Please enter the salary rate: ");
- scanf_s("%f", &rate);
- fflush(stdin);
- gross = (float)hours*rate;
- tax = gross*.1;
- printf("\nRetirement plan offers:");
- printf("\nS\tStandard Retirement Plan - %.2f(5%%) deducted from gross pay", gross*.05);
- printf("\nP\tPremium Retirement Plan - %.2f(8%%) deducted from gross pay", gross*.08);
- printf("\nN\tNo Retirement Plan");
- printf("\nPlease enter the letter of your choice: ");
- fflush(stdin);
- scanf_s(" %c", &plan);
- plan = toupper(plan);//this changes the character value to uppercase regardless of input
- if (plan == 'S') benefits = gross*.05;
- else if (plan == 'P') benefits = gross*.08;
- else if (plan == 'N') benefits = 0;
- else
- {
- printf("\nInvalid entry. No retirement plan selected. Proceeding.");
- benefits = 0;
- }
- printf("\nWould you like to add Medical insurance? (Php 1500)\nY/N :");
- fflush(stdin);
- scanf_s(" %c", &control);
- control = toupper(control);//this changes the character value to uppercase regardless of input
- if (control == 'Y') benefits = benefits + 1500;
- else if (control != 'N') printf("/nInvalid entry. Benefit not added to total.");
- printf("\nWould you like to add Life insurance? (Php 500)\nY/N :");
- fflush(stdin);
- scanf_s(" %c", &control);
- control = toupper(control);//this changes the character value to uppercase regardless of input
- if (control == 'Y') benefits = benefits + 500;
- else if (control != 'N') printf("/nInvalid entry. Benefit not added to total.");
- printf("\nWould you like to add Dental insurance? (Php 100)\nY/N :");
- fflush(stdin);
- scanf_s(" %c", &control);
- control = toupper(control);//this changes the character value to uppercase regardless of input
- if (control == 'Y') benefits = benefits + 100;
- else if (control != 'N') printf("/nInvalid entry. Benefit not added to total.");
- //input evaluation ends here, output next.
- printf("\nGross pay:\tPhp. %0.2f", gross);
- printf("\nTax deduction:\tPhp. %0.2f", tax);
- printf("\nTotal benefits:\tPhp. %0.2f", benefits);
- printf("\nNet pay:\tPhp. %.2f", gross - tax - benefits);
- printf("\n\nPress any key to end program.");
- _getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement