hi guys

how are you all, I sincerely hope that you all christmas is shaping up very good.
I am doing my individual assignment, yes another one, a take home this time, I am to implemented a payroll system into a company using a for loop and which i did.

the things is what was supposed to be outputting, it not exactly what it is supposed to be. I believe that something either had to be the calcalutions or I am missing some codes. I did the coding myself.

these are the outputs
the number of processed employees - am getting that
the employeess id num - am getting that also
first and last name - getting that
gross salary - am not getting that
net salary - am not getting that

the program should also generate a report with these information
the total number of processed employees - am not getting that
the number of commission paid workers - am not getting that
the number of hourly paid workers - am not getting that
the number of monthly paid workers - which am not getting
the total figure of all hourly paid, monthly paid and commission paid workers- am not getting that
the highest and lowest paid value workers - am not getting that

the program is generating a minus with everyone getting the same net pay - have no idea why
the hourly paid workers gross pay are calculated with time and a half which is 120 hours
all workers are to recieve a $5000 tax free allowance which the balance is tax at 25%

I have to do method. dont know if it is my methods is the culprit or if I am missing some codes or if my calculation is wrong. can u tell me what is wrong with my coding and calculation. guide me please thanks guys here is my codes and the output, you will see what I am talking about

public static double calGrossF(double gross_pay, double deduction)
    {   
        double total_deduction;

        total_deduction = gross_pay - deduction;
        return total_deduction;
      }
   public static double calGrossH(double hours_worked, double pay_rate)
      {
        double extra_time, over_time = 0;
        extra_time = hours_worked - 40;
        over_time = (pay_rate * 1.5) * extra_time;
        over_time = (40 * pay_rate)+ over_time;

        return extra_time;    
    }

    public static double calGrossC(double fixed_salary, double commission)
    {  
        double  fixedsalary, totalsales = 0;
        totalsales = totalsales * 5 /100;
        fixedsalary = fixed_salary + commission;
         return fixed_salary;         
    }
   public static double calDeductions(double grosspay, double taxes)
    {
        double gross_pay;
       gross_pay = grosspay - taxes;

        return gross_pay;

    }
    public static double calNetpay(double grosspay, double total_deductions)  
    {
     double netpay;
    netpay = grosspay - total_deductions;
    return netpay;

above is my methods that I am suppose to used to call the information below is my codes

This is my codes
for( i= 0; i<=3; i++)
        {
            System.out.println("please enter the number of employees to be processed");
            numofemp = read.nextInt();

            System.out.println("please enter employee id number");
            emp_idnum = read.nextInt();

            System.out.println("please enter employee first name");
            emp_firstname = read.next();

            System.out.println("please enter the employee surname");
            emp_surname = read.next();

            System.out.println("please enter the employee type code");
            emp_typecode = read.next();


            taxfree_allow = 5000;
            taxes = 025;
            deductions = (taxfree_allow * 25 / 100);

            total_deductions = calGrossF(gross_pay, deductions);
            extra_time = calGrossH(hours_worked, pay_rate);
            totalsales = calGrossC(fixed_salary, commission);
            gross_pay = calDeductions(grosspay, taxes);
            net_pay = calNetpay(grosspay, total_deductions);


            System.out.println("the number of employees to be process is " + numofemp);
            System.out.println("the employees id number is " + emp_idnum);
            System.out.println("the employees first name is " + emp_firstname);
            System.out.println("the employees surname is " + emp_surname);
            System.out.println("the employees type code is " + emp_typecode);


            System.out.println("payslip");
            payslip = read.nextLine();

            System.out.println("the employee id number is " + emp_idnum);
            System.out.println("the employees first name and surname is " + emp_firstname + emp_surname);
            System.out.println("the employee type code is " + emp_typecode);
            System.out.println("the employees gross pay is " + gross_pay);
            System.out.println("the total deduction is " + total_deductions);
            System.out.println("the netpay is " + net_pay);

            System.out.println("report");
            report = read.nextLine();

            System.out.println("the total number of processed employess is " + numofemp);
            System.out.println("the number of commission paid worker is " + comm_workers );
            System.out.println("the number of hourly paid workers is " + hourlypaid_workers);
            System.out.println("the number of monthly paid workers is " + monthly_paidworkers);
            System.out.println("the total culmative figure of gross pay,deductions and net pay of all employees are " + gross_pay + net_pay + deductions);

          if(num < lowest)
          {
              lowest = num;
          }
          if(num > highest)
          {
              highest = num;
          }
          if(num > 0)
          {
             count_pos++; 
          }
          if(num >0)
          {
              count_neg++;
          }
           System.out.println("the name and value of the highest paid employee is " + highest_paid);
           System.out.println("the name and value of the lowest paid employee is " + lowest_paid);
         }   
    }   
}

And this is the output
please enter the number of employees to be processed
89
please enter employee id number
1458
please enter employee first name
liselle
please enter the employee surname
johnson
please enter the employee type code
C
the number of employees to be process is 89
the employees id number is 1458
the employees first name is liselle
the employees surname is johnson
the employees type code is C
payslip
the employee id number is 1458
the employees first name and surname is lisellejohnson
the employee type code is C
the employees gross pay is -21.0
the total deduction is -1250.0
the netpay is 1250.0
report

the total number of processed employess is 89
the number of commission worker is 0
the number of hourly paid workers is 0
the number of monthly paid workers is 0
the total culmative figure of gross pay,deductions and net pay of all employees are -21.01250.01250.0
the name and value of highest paid employee is 0
the name and value of the lowest paid employee is 0
please enter the number of employees to be processed
85
please enter employee id number
6632
please enter employee first name
luana
please enter the employee surname
lemmison
please enter the employee type code
M
the number of employees to be process is 85
the employees id number is 6632
the employees first name is luana
the employees surname is lemmison
the employees type code is M
payslip
the employee id number is 6632
the employees first name and surname is luanalemmison
the employee type code is M
the employees gross pay is -21.0
the total deduction is -1271.0
the netpay is 1271.0
report

the total number of processed employess is 85
the number of commission worker is 0
the number of hourly paid workers is 0
the number of monthly paid workers is 0
the total culmative figure of gross pay,deductions and net pay of all employees are -21.01271.01250.0
the name and value of highest paid employee is 0
the name and value of the lowest paid employee is 0
please enter the number of employees to be processed
63
please enter employee id number
6254
please enter employee first name
jamie
please enter the employee surname
leston
please enter the employee type code
M
the number of employees to be process is 63
the employees id number is 6254
the employees first name is jamie
the employees surname is leston
the employees type code is M
payslip
the employee id number is 6254
the employees first name and surname is jamieleston
the employee type code is M
the employees gross pay is -21.0
the total deduction is -1271.0
the netpay is 1271.0
report

the total number of processed employess is 63
the number of commission worker is 0
the number of hourly paid workers is 0
the number of monthly paid workers is 0
the total culmative figure of gross pay,deductions and net pay of all employees are -21.01271.01250.0
the name and value of highest paid employee is 0
the name and value of the lowest paid employee is 0
please enter the number of employees to be processed
99
please enter employee id number
5214
please enter employee first name
marilyn
please enter the employee surname
manohar
please enter the employee type code
H
the number of employees to be process is 99
the employees id number is 5214
the employees first name is marilyn
the employees surname is manohar
the employees type code is H
payslip
the employee id number is 5214
the employees first name and surname is marilynmanohar
the employee type code is H
the employees gross pay is -21.0
the total deduction is -1271.0
the netpay is 1271.0
report

the total number of processed employess is 99
the number of commission worker is 0
the number of hourly paid workers is 0
the number of monthly paid workers is 0
the total culmative figure of gross pay,deductions and net pay of all employees are -21.01271.01250.0
the name and value of highest paid employee is 0
the name and value of the lowest paid employee is 0

Recommended Answers

All 3 Replies

well, usually, if your code doesn't do what you want it to do, that's a fair sign that something is wrong.

you don't show all your codes, so we can't know everything for sure. it would be best if you started step by step, so: don't post 10 things with the remar 'not getting this', rather post 1, be more clear about that one, and work towards that one.

chances are you'll be able to figure out on your own easily after someone helped you solve the first one. this 'll be easier for you to learn, and easier for other people to help you if they can fix on one problem at the time.

One small thing I noticed: line 23 - you return the wrong variable. And just before that the totalsales code makes no sense.

ok thanks again james cherrill

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.