Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class calcOps
- {
- public static String findGross(int hours, double rate)//gross pay
- {
- String grossPay="";
- double gross;
- int extraHours;
- if(rate>0)
- {
- if(hours>40)//checks if hours over 40
- {
- extraHours=hours-40;//gets num hours for overtime pay
- hours=40;
- gross=hours*rate;
- gross+=extraHours*(rate*1.5);
- grossPay=String.format("%1$,.2f",gross);//formats string
- }
- else//if 40 or less hours use regular hours*rate
- {
- gross=hours*rate;
- grossPay=String.format("%1$,.2f",gross);//formats string
- }
- }
- else//if no rate and/or no hours
- {
- gross=0.00;//gross set to 0
- grossPay=String.format("%1$,.2f",gross);//formats string
- }
- return grossPay;
- }
- public static String findFedTax(double gross)//fed tax
- {
- String fed="";
- double fedTax;
- gross-=300;
- fedTax=gross*.22;//taxes all income over 300
- fed=String.format("%1$,.2f",fedTax);//formats string
- return fed;
- }
- public static String getFica(double gross)//fica
- {
- String fica="";
- double ficaTax;
- ficaTax=gross*.085;//uses gross to find fica
- if(ficaTax>45)//sets max fica to 45
- ficaTax=45;
- fica=String.format("%1$,.2f",ficaTax);//formats string
- return fica;
- }
- public static String getHealthPrem(int dependents)//health premium
- {
- String premium="";
- double healthPrem;
- healthPrem=28.75+(dependents*17.35);//individual prem + num dependents*dependent rate
- premium=String.format("%1$,.2f",healthPrem);//formats string
- return premium;
- }
- public static String getNetPay(double grossMoney, double fedNum, double premiumNum, double ficaNum)//net pay
- {
- String net="";
- double netPay;
- netPay=grossMoney-fedNum-premiumNum-ficaNum;
- net=String.format("%1$,.2f",netPay);//formats string
- return net;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement