[/QUOTE][/HTML]How do I get the variable "nPay" to give me a result?
[QUOTE]
import java.util.Scann er;
public class WeeklyPay1
{
public static void main(String[] a)
{
String name; //Employee's name
String input; //Holds additional kb info
char married; //Married? y or n
char health; //Healthcare? y or n
double hours; //Hours worked by employee
double gPay; //Gross pay
double nDep; //Number of Dependents
double TaxPay; //Income that is taxable
double Taxes; //Holds tax rate for taxable pay
final double marDed= 150; //Standard Deductions for married
final double sDed = 75; //Standard Deductions for single
final double mMed=100; //Medical deductions for married
final double sMed=60; //Medical deductions for single
double nPay; //Employees Net Pay
Payroll1 getpaid = new Payroll1();
Scanner kb = new Scanner(System. in);
//Get the Employee's marital status
System.out.prin t("Are you Married? Y or N: ");
input = kb.nextLine();
married = input.charAt(0) ;
//Do you have Healthcare?
System.out.prin t("Do you have Healthcare: Y or N: ");
input = kb.nextLine();
health = input.charAt(0) ;
//Get Employee's name
System.out.prin t("Enter your name: ");
name = kb.nextLine();
//Get Employee's Pay Rate
System.out.prin t("Enter pay rate: ");
rate = kb.nextDouble() ;
//Get Employee's hours worked
System.out.prin t("Enter the number of hours you worked: ");
hours = kb.nextDouble() ;
//Get Employee's dependents
System.out.prin t("How many dependents do you have: ");
nDep = kb.nextDouble() ;
//Store the data
getpaid.setPayR ate(rate);
getpaid.setHrsW orked(hours);
getpaid.setDepe ndents(nDep);
//Determine if married, and determine tax bracket
if(married == 'Y' || married == 'y')
{
//Calculate taxable pay
TaxPay = getpaid.getGros sPay()- marDed - (70 * getpaid.getDepe ndents());
if (health == 'Y' || health == 'y')
TaxPay = TaxPay - 100;
if(TaxPay > 800)
Taxes = (TaxPay - 800) * .35 + (800 - 500) * .25 + (500 - 200) * .15 + 200 * .10;
else if (TaxPay > 500)
Taxes = (TaxPay -500) * .25 + (500-200) * .15 + 200 * .10;
else if (TaxPay > 200)
Taxes = (TaxPay -200) * .15 + 200 * .10;
else
Taxes = (TaxPay * .10);
}
else
{
TaxPay = getpaid.getGros sPay() - sDed - (70 * getpaid.getDepe ndents());
if(health == 'N' || health == 'n')
TaxPay -= 60;
if (TaxPay > 400)
Taxes = (TaxPay - 400) * .35 + (400 - 250) * .25 + (250 -100) * .15 + 100*.10;
else if (TaxPay > 250)
Taxes = (TaxPay - 250) * .25 + (250 - 100) * .15 + 100 * .10;
else if (TaxPay > 100)
Taxes = (TaxPay - 100) * .15 + 100 * .10;
else
Taxes = TaxPay * .10;
}
nPay = getpaid.getGros sPay() - mMed; // - Taxes;
System.out.prin tln("Net Pay " + nPay);
}
}
}
}
[QUOTE]
import java.util.Scann er;
public class WeeklyPay1
{
public static void main(String[] a)
{
String name; //Employee's name
String input; //Holds additional kb info
char married; //Married? y or n
char health; //Healthcare? y or n
double hours; //Hours worked by employee
double gPay; //Gross pay
double nDep; //Number of Dependents
double TaxPay; //Income that is taxable
double Taxes; //Holds tax rate for taxable pay
final double marDed= 150; //Standard Deductions for married
final double sDed = 75; //Standard Deductions for single
final double mMed=100; //Medical deductions for married
final double sMed=60; //Medical deductions for single
double nPay; //Employees Net Pay
Payroll1 getpaid = new Payroll1();
Scanner kb = new Scanner(System. in);
//Get the Employee's marital status
System.out.prin t("Are you Married? Y or N: ");
input = kb.nextLine();
married = input.charAt(0) ;
//Do you have Healthcare?
System.out.prin t("Do you have Healthcare: Y or N: ");
input = kb.nextLine();
health = input.charAt(0) ;
//Get Employee's name
System.out.prin t("Enter your name: ");
name = kb.nextLine();
//Get Employee's Pay Rate
System.out.prin t("Enter pay rate: ");
rate = kb.nextDouble() ;
//Get Employee's hours worked
System.out.prin t("Enter the number of hours you worked: ");
hours = kb.nextDouble() ;
//Get Employee's dependents
System.out.prin t("How many dependents do you have: ");
nDep = kb.nextDouble() ;
//Store the data
getpaid.setPayR ate(rate);
getpaid.setHrsW orked(hours);
getpaid.setDepe ndents(nDep);
//Determine if married, and determine tax bracket
if(married == 'Y' || married == 'y')
{
//Calculate taxable pay
TaxPay = getpaid.getGros sPay()- marDed - (70 * getpaid.getDepe ndents());
if (health == 'Y' || health == 'y')
TaxPay = TaxPay - 100;
if(TaxPay > 800)
Taxes = (TaxPay - 800) * .35 + (800 - 500) * .25 + (500 - 200) * .15 + 200 * .10;
else if (TaxPay > 500)
Taxes = (TaxPay -500) * .25 + (500-200) * .15 + 200 * .10;
else if (TaxPay > 200)
Taxes = (TaxPay -200) * .15 + 200 * .10;
else
Taxes = (TaxPay * .10);
}
else
{
TaxPay = getpaid.getGros sPay() - sDed - (70 * getpaid.getDepe ndents());
if(health == 'N' || health == 'n')
TaxPay -= 60;
if (TaxPay > 400)
Taxes = (TaxPay - 400) * .35 + (400 - 250) * .25 + (250 -100) * .15 + 100*.10;
else if (TaxPay > 250)
Taxes = (TaxPay - 250) * .25 + (250 - 100) * .15 + 100 * .10;
else if (TaxPay > 100)
Taxes = (TaxPay - 100) * .15 + 100 * .10;
else
Taxes = TaxPay * .10;
}
nPay = getpaid.getGros sPay() - mMed; // - Taxes;
System.out.prin tln("Net Pay " + nPay);
}
}
}
}
Comment