Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(CSIS-130)(Java program)(Solve ASAP please. Thanks.)(I just need an answer for Q5&Q6) public class Demo { public static void main(String[] args) { //Q0) make an HourlyEmployee

(CSIS-130)(Java program)(Solve ASAP please. Thanks.)(I just need an answer for Q5&Q6)

public class Demo {

public static void main(String[] args) {

//Q0) make an HourlyEmployee called he => Khaled, 1/2/2000, rate 20 , hours 50

// make a SalariedEmployee called se1 => Ali, 1/2/2014, salary 2000

// make a SalariedEmployee called se2 => Salem, 2/5/2010, salary 1000

// make a ManagementEmployee me => Fay, 1/3/2012, salary 3000 and bonus 2000

Employee he = new Employee("hourly", "Khaled","1/2/2000");

he.setHour(50);

he.setRate(20);

Employee se1= new Employee("salaried", "Ali","1/2/2014");

se1.setSalary(2000);

Employee se2= new Employee("salaried", "Salem","2/5/2010");

se2.setSalary(1000);

Employee me = new Employee("management","Fay","1/3/2012");

me.setBonus(2000);

me.setSalary(3000);

// Q1) Make an array of Employee called empA containing he, se1, se2 and me

Employee[] empA = {he,se1,se2,me};
 double totalPay=0.0;

// Q2) Write code to print out the total pay for all employees

for(int i=0;i 
 if(empA[i].type=="hourly"){
 totalPay=totalPay+empA[i].hour*empA[i].rate;
 }
 else if(empA[i].type=="salaried"){
 totalPay=totalPay+empA[i].salary;
 }
 else if(empA[i].type=="management"){
 totalPay=totalPay+empA[i].salary+empA[i].bonus;
 }
 }
 System.out.println("Total Pay : "+totalPay);
 totalPay=0.0;
 int count=0;

// Q3) Write code to print out the total pay for only the salaried employees

// use enhanced for loop and test with instanceof. Also count them.

for(int i=0;i 
 if(empA[i].type=="salaried"){
 totalPay=totalPay+empA[i].salary;
 count++;
 }
 }
 System.out.println("Salaried : Total Pay : "+totalPay+" Count : "+count);
 totalPay=0.0;

// Q4) Write code to print out the total pay for only the hourly employees

// use enhanced for loop and test with getClass() method

for(int i=0;i 
 if(empA[i].type=="hourly"){
 totalPay=totalPay+empA[i].hour*empA[i].rate;
 }
 }
 System.out.println("Hourly Employees : Total Pay : "+totalPay);
 totalPay=0.0;
 }
}

// Q5) Loop empA and work out the total tax for Taxable staff.. and count them

// Q6) Loop empA and work out the total extra tax only.. and count them

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Moving Objects Databases

Authors: Ralf Hartmut Güting, Markus Schneider

1st Edition

0120887991, 978-0120887996

More Books

Students also viewed these Databases questions

Question

Explain the chemical properties of acids with examples.

Answered: 1 week ago

Question

Write the properties of Group theory.

Answered: 1 week ago

Question

13-4 What are alternative methods for building information systems?

Answered: 1 week ago