Can anyone tell me y is it that taxDeduc won't return the value?

import java.util.Scanner;
public class PayollComputation {

    
    public static void main(String[] args) throws Exception{
    Scanner get = new Scanner(System.in);
    
        //variable declaration
    int ctr, loc = -1, payrollPeriod, daysAbsent, minsLate, oTHours;
    int tempENo = 0;
    char ans, ans2;
    String tempNa;
    float pagibigDeduc, otherDeduc, basicPay, dailyRate, hourRate, minRate,
            oTPay, lateDeduc, absentDeduc, lateAbsentDeduc, grossPay,
            sssDeduc, taxDeduc, totalDeduc, netPay;
        //arrays
    int[] empNo = {1001, 1002, 1003, 1004};
    String[] empNa = {"M. Jordan", "K. Bryant", "B. Pares", "D. Howard"};
    float[] ratePerMonth = {15000, 10000, 18000, 20000};
    
    dailyRate = 0;
    hourRate = 0;
    minRate = 0;
    pagibigDeduc = 0;
        //1st window
    System.out.println("***************************************");
    System.out.println("Payroll Computation System\n" +
                       "by Krishia Valencia\n");
    System.out.print("Enter Payroll Period[1/2]: ");
     payrollPeriod = get.nextInt();
     
        if(payrollPeriod == 1){
            pagibigDeduc = 100;
            sssDeduc = 0; }
        else if (payrollPeriod == 2) 
            pagibigDeduc = 0;
    System.out.println();
    System.out.println("***************************************");
     //2nd window
    System.out.println("Payroll Computation System");
    System.out.println("Date Entry Section\n");
    System.out.print("Enter Employee No.: ");
      tempENo = get.nextInt();
    System.out.print("Enter OT Hours    : ");
      oTHours = get.nextInt();
    System.out.print("Enter Days Absent : ");
      daysAbsent = get.nextInt();
    System.out.print("Enter No. of Minutes Late: ");
      minsLate = get.nextInt();
    System.out.print("Enter Other Deductions   : ");
      otherDeduc = get.nextFloat();
    System.out.println();
    System.out.print("Enter 'C' to continue or 'X' to quit: ");
     ans = (char)System.in.read();
     System.in.read();
    System.out.println();
    System.out.println("***************************************");
if(ans == 'c' || ans =='C') {

        //3rd window
    System.out.println("Payroll Computation System");
    System.out.println("Employee Payslip \n");
    
    for(ctr = 0; ctr < empNo.length; ctr++ )
        if(empNo[ctr] == tempENo) {
            loc = ctr;
            break; }    //end of if{}
    
    if (loc >= 0) {
        tempENo = empNo[ctr];
        tempNa = empNa[ctr];
        
        sssDeduc = 0;
        taxDeduc = 0;
        netPay = 0;
            //computations
        basicPay = ratePerMonth[ctr] / 2;
        dailyRate = ratePerMonth[ctr] / 26;
        hourRate = dailyRate / 8;
        minRate = hourRate / 480;
        oTPay = (hourRate * 1.25f) * oTHours;
        lateDeduc = minRate * minsLate;
        absentDeduc = dailyRate * daysAbsent;
        lateAbsentDeduc = lateDeduc + absentDeduc;
        grossPay = (basicPay + oTPay) - (absentDeduc + lateDeduc);
        totalDeduc = (sssDeduc + pagibigDeduc) + (taxDeduc + otherDeduc);
        netPay = ratePerMonth[ctr] - totalDeduc;
            
            //sssDeduc
        if((grossPay > 15000) && (payrollPeriod == 2))
            sssDeduc = 500;
        else if ((grossPay >= 10000 && grossPay <= 15000) && (payrollPeriod == 2))
            sssDeduc = 300;
        else if ((grossPay >= 5000 && grossPay <= 9999) && (payrollPeriod == 2))
            sssDeduc = 200;
        else if ((grossPay >= 2500 && grossPay <= 4999) && (payrollPeriod == 2)) 
            sssDeduc = 100;
        else if ((grossPay < 2500) && (payrollPeriod == 2))
            sssDeduc = 0;


        totalDeduc = (sssDeduc + pagibigDeduc) + (taxDeduc + otherDeduc);
        netPay = ratePerMonth[ctr] - totalDeduc;
        
        
        System.out.println("Employee No.  => " + tempENo);
        System.out.println("Name          => " + tempNa);
        System.out.printf("Basic Pay     => %8.2f\n", basicPay);
        System.out.printf("Overtime Pay  => %8.2f\n", oTPay); 
        System.out.printf("Late/Absences => %8.2f\n", lateAbsentDeduc);
        System.out.printf("Grosspay      => %8.2f\n", grossPay);
        System.out.printf("SSS Ded.      => %8.2f\n", sssDeduc);
        System.out.printf("Tax Ded.      => %8.2f\n", taxDeduc);
        System.out.printf("Pag-ibig      => %8.2f\n", pagibigDeduc); 
        System.out.printf("Other Ded.    => %8.2f\n", otherDeduc); 
        System.out.printf("total Deductions . . . . %8.2f\n", totalDeduc);
        System.out.printf("Netpay . . . . . . . . . %8.2f\n", netPay);  
        System.out.println("**************************************");
        }//end of if(loc)
}//end of while

    }//end main
    
    public static float taxDeduc(float grossPay, float taxDeduc) {
       
                    //taxDeduc
        if(grossPay > 15000) 
            taxDeduc = grossPay * .3f;
        else if (grossPay >= 10000 && grossPay <= 15000)
            taxDeduc = grossPay * .2f;
        else if (grossPay >= 5000 && grossPay <= 9999)
            taxDeduc = grossPay * .1f;
        else if (grossPay >= 2500 && grossPay <= 4999)
            taxDeduc = grossPay * .05f;
        else if (grossPay < 2500)
            taxDeduc = 0;
        return taxDeduc;}
}

I wanted to make a separate method for the taxDeduc but I It won't return the value. This is the first time I used predefined method so I'm getting lost here..

If I remove it from the method and put it back to main, it works fine

:) thank you so much! u'r right.. the link is also a big help

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.