hi guys
havent been here for a while. I am practicing this program for a few days now I havent seen no syntax error but am not getting any output.
the program is about a loan officer for two group of employees for a credit union. the regular staff salaries are generated by the amt of hours work by their rate of pay and the loan officer salaries are calculated by thier commission based system and they received a fixed salary less 3 % interest on all loans issued for the month.

this is what I have so far, can someone tell me if there is anything that I may have to add/do to get an output because right now, am getting nothing as the output, so tell me where I have gone wrong and how it can be fixed and what can be implemented to get it right
here is what i have so far. any input would do and please dont be hard on me.

public class Loan
{
    public static void main(String[]args)
    {
        Scanner scnr = new Scanner(System.in);

         Loan loan = new Loan();

    }
    private String loanOfficerID, fullName, lastName;
    private double loanInterest;
    private double fixedSalary;
    private double grossPay;
    private final double healthSurcharge = 8.50;
    private double totalDeduction;
    private double NIS;
    private double netpay;
    private double hoursWork;
    private double rateOfpay;

    public String loanOfficerID()
    {
        return loanOfficerID;
    }
    public void setloanOfficerID(String loanOfficerID)
    {
        this.loanOfficerID = loanOfficerID;
    }
    public String getfullName()
    {
        return fullName;
    }
    public void setfullName(String fullName)
    {
        this.fullName = fullName;
    }
    public String getlastName()
    {
        return lastName;
    }
    public void setlastName(String lastName)
    {
        this.lastName = lastName;
    }
    public double gethoursWork()
    {
        hoursWork = hoursWork * rateOfpay ;
        return hoursWork;
    }
    public void sethourWork(double hoursWork)
    {
        this.hoursWork = hoursWork;
    }
    public double getloanInterest()
    {
        loanInterest = loanInterest * 0.3;
        grossPay = loanInterest - grossPay;

        return loanInterest;
    }
    public void setloanInterest(double loanInterest)
    {
        this.loanInterest = loanInterest;
    }
    public double getfixedSalary()
    {
        fixedSalary = fixedSalary + grossPay;
        fixedSalary = fixedSalary * 0.3;
        return fixedSalary;
    }
    public void setfixedSalary(double fixedSalary)
    {
        this.fixedSalary = fixedSalary;
    }
    public double gethealthSurcharge()
    {
        return healthSurcharge;
    }
     public void sethealthSurcharge(double healthSurcharge)
    {
        healthSurcharge = 8.50;
    }
    public double getNIS()
    {
        return NIS;
    }
    public void setNIS(double NIS)
    {
        this.NIS = NIS;
    }
    public double gettotalDeduction()
    {
        totalDeduction = NIS + healthSurcharge;

        return totalDeduction;
    }
    public void settotalDeduction(double totalDeduction)
    {
        this.totalDeduction = totalDeduction;
    }
    public double getnetpay()
    {
        netpay = totalDeduction - grossPay;

        return netpay;
    }

    public void details()
    {
        System.out.println("The loan officer id number is: "+loanOfficerID);
        System.out.println("The loan officer full and last name are: "+fullName + " "+ lastName);
        System.out.println("The gross pay is: "+grossPay);
        System.out.println("The total deduction is: "+totalDeduction);
        System.out.println("The netpay is: "+netpay);

    }

Recommended Answers

All 3 Replies

You have a load of get methods that change the values of your variables, eg

 public double gethoursWork()
    {
        hoursWork = hoursWork * rateOfpay ;
        return hoursWork;
    }

now suppose hoursWork starts out at 10, and rateOfpay is 8
call getHoursWork and it will return 80
call it again and it will return 640
(etc)
That's obviously very wrong. And there are other methods just like that.

To see the output you have to call the method that produces the output - in this case it's details() Before that you probably want to call some of the setters and getters to create some test data.

Divide your variables into those that are input (eg hours worked) and those that are calculated (eg net pay).
Input variables should have setter methods, and should never be changed by any other methods.
Calculated variables should NOT have setter methods. They should be calculated inside their getter methods. If calling a getter twice consecutively gives 2 different results then that's almost certainly an error.

hi james
I did not get it to work, i run the wrong program. it still giving me the same zero output even though i did wat u had suggested but i am wondering where i have gone wrong. here is the revised codes.

 private String loanOfficerID, fullName, lastName;
    private double loanInterest;
    private double fixedSalary;
    private double grossPay;
    private final double healthSurcharge = 8.50;
    private double totalDeduction;
    private double netpay;
    private double hoursWork;
    private double rateOfpay;
    private double result;

    public String getloanOfficerID()
    {
        return loanOfficerID;
    }
    public void setloanOfficerID(String loanOfficerID)
    {
        this.loanOfficerID = loanOfficerID;
    }
    public String getfullName()
    {
        return fullName;
    }
    public String getlastName()
    {
        return lastName;
    }
    public double getcalculation(double hoursWork, double loanInterest, double fixedSalary, double healthSurchare,double NIS, double totalDeduction,double grossPay, double netPay)
    {
        this.hoursWork = hoursWork * rateOfpay;
        this.loanInterest = loanInterest * 0.3;
        this.fixedSalary = fixedSalary * 0.3;
        this.grossPay = fixedSalary + grossPay;
        this.grossPay = loanInterest - grossPay;
        this.totalDeduction = NIS + healthSurcharge;
        this.netpay = grossPay - totalDeduction;

        return result;
    }
    public void details()
    {
        System.out.println("The loan officer ID number is: "+loanOfficerID);
        System.out.println("The loan officer full and last name is: "+ fullName+" "+ lastName);
        System.out.println("The total deduction is:"+totalDeduction);
        System.out.println("The gross pay is:$"+grossPay);
        System.out.println("The netpay is:$ "+netpay);
    }

I'm sorry, but what you have done there is nothing like what I suggested. And I already explained why you have no output. Please re-read my previous post carefully.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.