methods returning zero's ???
Will someone look at this and maybe give a pointer on why only zero's are being returned.
public class employee {
String name;
int id;
int salary;
int age;
String position;
void display(){
System.out.println("Federal Tax" +getFedTax);
System.out.println("Social Security Tax" +getSsTax);
System.out.println("Health Fee" +getHealthFee);
System.out.println("Insurance" +getInsurance);
System.out.println("Net Pay" +getNetPay);
}
int getFedTax;
int fedtax = salary;
double fedtax1 = (fedtax-800)*.17;
int getSsTax;
int sstaxrate = 5;
double sstax = salary*.05;
int getHealthFee;
int healthrate = 5;
double healthfee = salary*.05;
int getInsurance;
int insurancerate;
{
if (age<40)
insurancerate = 3;
else if(age<=50)
insurancerate = 4;
else if(age<=60)
insurancerate = 5;
else if(age>60)
insurancerate = 6;
getInsurance = ((insurancerate*10^-3)*salary);
}
double getNetPay;
double netpay = salary-fedtax1-sstax-healthfee-getInsurance;
}
HERE IS MY MAIN CLASS
public class employeeMain {
public static void main(String[] args) {
{
employee employee1 = new employee();
employee1.name = "dave johnson";
employee1.id = 1234;
employee1.salary = 50000;
employee1.age = 45;
employee1.position = "supervisor";
employee1.display();
}
}
}
Re: methods returning zero's ???
you used 'getFedTax', 'getSsTax', 'getHealthFee', 'getInsurance', and 'getNetPay' for display() but
you actually never used those and even didn't initialize values for them.
and just wondering, aren't those getSmth methods?
Re: methods returning zero's ???
I thought the data i put in the employeeMain would go into those methods. I need to look back at my notes but, maybe I put a { after the method name to initialize?
Re: methods returning zero's ???
those are not even methods yet....
Quote:
int getSsTax;
int sstaxrate = 5;
double sstax = salary*.05;
getSsTax is still integer, not method
if getSsTax is a method then.... it should be like
Quote:
public int getSsTax(){
// code....
}
Re: methods returning zero's ???
Alright I think that'll get me on the right path - thanks