Advertisement
darkhelmet125

calcOps.java

Sep 27th, 2012
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.17 KB | None | 0 0
  1. public class calcOps
  2. {
  3.     public static String findGross(int hours, double rate)//gross pay
  4.     {
  5.         String grossPay="";
  6.         double gross;
  7.         int extraHours;
  8.         if(rate>0)
  9.         {
  10.             if(hours>40)//checks if hours over 40
  11.             {
  12.                 extraHours=hours-40;//gets num hours for overtime pay
  13.                 hours=40;
  14.                 gross=hours*rate;
  15.                 gross+=extraHours*(rate*1.5);
  16.                 grossPay=String.format("%1$,.2f",gross);//formats string
  17.             }
  18.             else//if 40 or less hours use regular hours*rate
  19.             {
  20.                 gross=hours*rate;
  21.                 grossPay=String.format("%1$,.2f",gross);//formats string
  22.             }
  23.         }
  24.         else//if no rate and/or no hours
  25.         {
  26.             gross=0.00;//gross set to 0
  27.             grossPay=String.format("%1$,.2f",gross);//formats string
  28.         }
  29.         return grossPay;
  30.     }
  31.     public static String findFedTax(double gross)//fed tax
  32.     {
  33.         String fed="";
  34.         double fedTax;
  35.         gross-=300;
  36.         fedTax=gross*.22;//taxes all income over 300
  37.         fed=String.format("%1$,.2f",fedTax);//formats string
  38.         return fed;
  39.     }
  40.     public static String getFica(double gross)//fica
  41.     {
  42.         String fica="";
  43.         double ficaTax;
  44.         ficaTax=gross*.085;//uses gross to find fica
  45.         if(ficaTax>45)//sets max fica to 45
  46.             ficaTax=45;
  47.         fica=String.format("%1$,.2f",ficaTax);//formats string
  48.         return fica;
  49.     }
  50.     public static String getHealthPrem(int dependents)//health premium
  51.     {
  52.         String premium="";
  53.         double healthPrem;
  54.         healthPrem=28.75+(dependents*17.35);//individual prem + num dependents*dependent rate
  55.         premium=String.format("%1$,.2f",healthPrem);//formats string
  56.         return premium;
  57.     }
  58.     public static String getNetPay(double grossMoney, double fedNum, double premiumNum, double ficaNum)//net pay
  59.     {
  60.         String net="";
  61.         double netPay;
  62.         netPay=grossMoney-fedNum-premiumNum-ficaNum;
  63.         net=String.format("%1$,.2f",netPay);//formats string
  64.         return net;
  65.     }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement