วันอังคารที่ 9 กันยายน พ.ศ. 2557

Calculate Income Tax

โปรแกรมคำนวนภาษี !!



void setup(){
    //initialization
    size(300,100);
    background(255);
    //variable
    int income;
    //assign variable
    income = 800001;
    //calculate tax
    println("Tax = "+CalTax(income)+" Baht");
    fill(0);
    textSize(25);
    text("Tax = "+CalTax(income)+" Baht",20,40);
}
void CalTax(i){
    int tax;
    if(i>800000){
        tax = (25/100)*i;
        }else{
            if(i>500000){
                tax = (20/100)*i;
                }else{
                    if(i>300000){
                        tax = (15/100)*i;
                        }else{
                            if(i>150000){
                                tax = (10/100)*i;
                                }else{
                                    tax = 0;
                                    }}}}
    return tax;
}