Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Payroll Calculator

$
0
0
Can anyone please tell me why my values wont pass through the methods? It keeps printing zero for the output. Don't mind the comments.

import java.util.Scanner;

public class work
{

    public static void main(String[] args)
    {
        double  ot1, ot2, gp = 0, d , reduction, gpr = 0, taxincome = 0, np, income = 0;

       Scanner keyboard = new Scanner(System.in);

       System.out.println("How many hours were worked? ");
       double hours = keyboard.nextDouble();

       System.out.println("What is your hourly pay? ");
       double pay = keyboard.nextDouble();

       System.out.println("How many dependents do you have? ");
       double dependent = keyboard.nextDouble();

       reduction = taxable_income(dependent,gp);
       System.out.println(reduction);


       gpr = taxes(gpr);
       System.out.println(gpr);


       if(hours > 40 && hours < 60)
       {
            ot1 = (hours * .5) * hours;
            gp = ot1 * pay;
            //System.out.println(gp);
        }
       else if(hours > 60)
       {
           ot2 = (hours * 2) * hours;
           gp = ot2 * pay;
           //System.out.println(gp);
        }

    }


       public static double taxable_income(double dependent, double gp)
       {
           double reduction = 0;

           if(dependent <= 0)
           {
               dependent = 0;
            }


           if(dependent > 0 && dependent < 2)
           {
               dependent = .04;
            }


           if(dependent > 1 && dependent < 3)
           {
               dependent = .0775;
            }


           if(dependent > 2 && dependent < 4)
           {
               dependent = .1125;
            }


           if(dependent > 3 && dependent < 5)
           {
               dependent = .145;
            }


           if(dependent > 4 && dependent < 5)
           {
               dependent = .175;
            }


           if(dependent >= 6)
           {
               dependent = .2025;
            }

            reduction = gp * dependent;
            

            return reduction;

        }

       public static double taxes(double gpr)
       {
           double income = 0, taxincome = 0;


           if(income >= 0 && income <= 500)
           {
              taxincome  = gpr * .10;
            }


           if(income >= 501 && income <= 1000)
           {
               taxincome  = gpr * .15;
            }


           if(income >= 1001 && income <= 1500)
           {
               taxincome  = gpr * .25;
            }

           if(income >= 1501 && income <= 2000)
           {
               taxincome  = gpr * .40;
            }


           if(income >= 2001)
           {
               taxincome  = gpr * .50;
            }

            
            //taxincome = gpr;

            return gpr;
        }

           


    }


Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>