Skip to content

Instantly share code, notes, and snippets.

@iammarkps
Created October 29, 2019 12:37
Show Gist options
  • Save iammarkps/0bf28b6d811c815f0824c4b02fda6955 to your computer and use it in GitHub Desktop.
Save iammarkps/0bf28b6d811c815f0824c4b02fda6955 to your computer and use it in GitHub Desktop.
#include <bits/stdc++.h>
#define long long long
using namespace std;
int age, children, parents, disabled;
long income;
char name[100], input;
int main() {
printf("\n================================\n");
printf(" Tax Calculator 2017 \n");
printf("================================\n\n");
printf("Enter your name: ");
scanf(" %s", name);
printf("Enter your age: ");
scanf("%d", &age);
if(age < 18) {
printf("You do not have to pay tax\n");
return 0;
}
printf("Enter your income: ");
scanf("%lld", &income);
income -= 60000ll;
printf("Is your spouse a taxpayer (Y/N): ");
scanf(" %c", &input);
if(input == 'N') income -= 60000ll;
printf("How many children do you have : ");
scanf("%d", &children);
if(children > 0) income -= 30000ll * children;
printf("Do you in need of maternity expense (Y/N): ");
scanf(" %c", &input);
if(input == 'Y') income -= 60000ll;
printf("How many of your parents you are taking care of : ");
scanf("%d", &parents);
if(parents > 0) income -= 30000ll * parents;
printf("How many disabled are you in charge of : ");
scanf("%d", &disabled);
if(disabled > 0) income -= 60000ll * disabled;
printf("\n================================\n");
printf("Your net income after deduction : %lld\n baht", max(income, 0ll));
double tax;
if(income <= 150000) tax = 0;
else if(income <= 300000) tax = 0.05 * income;
else if(income <= 500000) tax = 0.10 * income;
else if(income <= 750000) tax = 0.15 * income;
else if(income <= 1000000) tax = 0.20 * income;
else if(income <= 2000000) tax = 0.25 * income;
else if(income <= 5000000) tax = 0.30 * income;
else tax = 0.35 * income;
printf("Amount of tax you need to pay : %.3f baht\n", tax);
printf("================================\n\n");
printf("Thank you for using our service, Mr./Mrs. %s\n", name);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment