someone explain this please

+1 Anthony St John · August 3, 2014
Hi i have a problem for an assignment im doing for procedural programming class but the problem i was given doesn't make sense to me, the problem is shown below: 

Triad Cleaning Services Limited (TCS) pays an annual bonus to its employees. The bonus is based on the number of years
the employee has been with the company. Employees working at the company for less than 5 years receive a bonus equal
to 3% percent of their annual salary; between 5 and 10 years receive a bonus equal to 4% of their annual salary; all
others receive a bonus equal to 5% of their annual salary.
Presently, TCS undertakes this annual endeavour by manually poring through Employee paper based files and
meticulously documenting each employee’s years of service before passing it to the accounts department. TCS’ employee
base has been expanding yearly and this manual process is fast becoming tedious. In light of the growing employee base,
the accounts department has requested a computerized system that would store all employee data and allow it to generate
the bonus calculations automatically.

The proposed solution must:
1. Store all employee data. 
Employee data would consist of Employee ID, Name, Date of Hire, Basic Monthly Salary
and Department. (NOTE: This can be a pre-initialized set of values in an array)

2. Print End of Year Payslip inclusive of Bonus Paid for each Employee. [See Sample Below.]
Name: Jack Sparrow
Department: Maintenance
Pay Period: December 2014
Basic Pay: $2,300.00
Annual Bonus: $ 828.00

3. Print reports as follows:
a. # of Employees in each bonus category (i.e. less than 5 years, between 5 and 10 years, over ten years’ service).
b. Total $ value paid in each bonus category
c. Total $ value paid in Annual Bonuses



#1 is no issue, #2 is kinda tricky cuz i'm having trouble wit the annual bonus part but #3 is the most problematic for me. I can make the arrays to store the information but am not sure as how to do what #3 is asking with with arrays. Does this question make sense to anyone or even seems solvable, side note im new to programming not very experienced. Any clarification will be greatly appreciated.

Post a Reply

Replies

- page 1
Oldest  Newest  Rating
+2 Pere Garau Burguera · August 3, 2014
It's not very difficult to make, but I think you should provide your code or what you have done so far and what errors or problems are you having.

To give you an idea, you need to loop through all employees, and each time, you have to increase the corresponding value to the results. I mean, if that employee is 4 years there, you have to increase a variable that will count how many 4-year employees there are, and the same with the others. 
0 Anthony St John · August 3, 2014
Now when i say i'm new to programming i literally mean new like 2 months in so what you're saying i'm kinda lost. here's the code i have so far it's kinda butchered:
http://i59.tinypic.com/w8s60y.jpg
0 Pere Garau Burguera · August 3, 2014
I recommend you to create an Employee class with the attributes name, department, years... 

This is the first step you have to do. It will make a lot more sense
0 Anthony St John · August 3, 2014
When you say employee class you mean like

public class employees {

empName;
empDepartment;
empID;
empBasicpay;

}
0 Pere Garau Burguera · August 3, 2014
Yeah, a class that contains all info for the employees.
0 Anthony St John · August 3, 2014
ok thanks i'll try it and post back
0 Anthony St John · August 3, 2014
I started the class but i realised am i supposed to use an array to store the information still? Since it's for 6 employees, cuz i gotta store the name, id department etc for each diff employee.
0 Pere Garau Burguera · August 4, 2014
You will need some kind of storage, like regular arrays, or Lists, but that doesn't have to do with the Employee class. Each class has the info of 1 employee, and from the main class you will create 6 objects instances of Employee, that are going to be stored somehow. 
0 Anthony St John · August 5, 2014
is this what you're talking about? 

package javaapp;
import java.util.Scanner;

//How to get and print input from a user

public class JavaApp {
    
    public static void main(String[] args) {
        
          double empannualSalary = 0;  
          double annualBonus = 0;
          int userChoice = 0;
          String inputChoice;
          String empDepartment;
          double categoryOne = 0;
          double categoryTwo = 0;
          double categoryThree = 0;
          double annualSalary = 0;
          
          
        class employeeOne{
            String  employeeNames[]= {"Kevin Lewis"};
            String  employeeDepartment[] = {"Accounting"};
            String  employeepayPeriod[] = {"July"};
            int  employeepayYear[] = {2004};
            int  empyearsWorked[] = {10};
            double  empbasicPay[] = {7000}; 
            
        } // end class employeeOne
        
        class employeeTwo{
            String  employeeNames[]= {"Candice Adams"};
            String  employeeDepartment[] = {"Information Technology"};
            String  employeepayPeriod[] = {"May"};
            int  employeepayYear[] = {2010};
            int  empyearsWorked[] = {4};
            double  empbasicPay[] = {8000}; 
        }// end class employeeTwo
         
        class employeeThree{
            String  employeeNames[]= {"Alvin Charles"};
            String  employeeDepartment[] = {"Sales"};
            String  employeepayPeriod[] = {"June"};
            int  employeepayYear[] = {2012};
            int  empyearsWorked[] = {2};
            double  empbasicPay[] = {5000};
        } // end class employeeThree
        
        class employeeFour{
            String  employeeNames[]= {"Cheryl Cole"};
            String  employeeDepartment[] = {"Administration"};
            String  employeepayPeriod[] = {"September"};
            int  employeepayYear[] = {2009};
            int  empyearsWorked[] = {5};
            double  empbasicPay[] = {5000};
        } // end class employeeFour
        
        class employeeFive{
            String  employeeNames[]= {"Samantha Rambert"};
            String  employeeDepartment[] = {"Clerical"};
            String  employeepayPeriod[] = {"October"};
            int  employeepayYear[] = {2011};
            int  empyearsWorked[] = {3};
            double  empbasicPay[] = {4000};
        } // end class employeeFive
        
        class employeeSix{
            String  employeeNames[]= {"John Doe"};
            String  employeeDepartment[] = {"Human Resources"};
            String  employeepayPeriod[] = {"March"};
            int  employeepayYear[] = {2005};
            int  empyearsWorked[] = {9};
            double  empbasicPay[] = {9000};
        } // end class eomployeeSix
        
        
           
             
                       
    }// End main
        
}//End class
+1 Pere Garau Burguera · August 5, 2014
Well, I'm sorry if maybe I explained this wrong. You have to create only ONE employee class. It's when you create an object from this class when you give it (or assign it) each particular employee info. Classes are blueprints for objects, so classes themselves only contain atributes and methods, but not any particular information. You have done the same work 6 times, by creating a class for each employee. It's like rewriting the same for 6 times. I would do something like this: 

public class Employee{


//attributes for the Employee class
private int id;
private String name;
private String department;
private String payPeriod;
private int payYear;
private int yearsWorked;
private int basicPay;

//constructor
public Employee(int id, String name, String department, String payPeriod, int payYear,
int yearsWorked, int basicPay){

this.id = id;
this.name = name;
this.department = department;
this.payPeriod = payPeriod;
this.yearsWorked = yearsWorked;
this.basicPay = basicPay;

}

//methods

public int getId(){
return id;
}

public String getName(){
return name;
}

//you can add the getter methods you need, it's just the same everytime


}
  • 1
  • 2

Java / Android Development

106,937 followers
About

Very popular language used to create desktop applications, website applets, and Android apps.

Links
Moderators
Bucky Roberts Administrator