Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

can anybody help me with this? condiser the following class: public class Worker

ID: 3833051 • Letter: C

Question

can anybody help me with this?

condiser the following class:

public class Worker {

private String name;
private double rate;
private int age;

public Worker(String name, double rate, int age) {
this.name = name;
this.rate = rate;
this.age = age;
}

public String getName() {
return name;
}

public double getRate() {
return rate;
}

public int getAge() {
return age;
}

public void setName(String name) {
this.name = name;
}

public void setRate(double rate) {
this.rate = rate;
}

public void setAge(int age) {
this.age = age;
}


}

next write a Test class for the following tasks:

1- implment worker class. 2- declare an arraylist of Worker objects in other class call it TestClass.

3- Add 100 Worker objects to the Arraylist, usng the forumla

if/is odd number, name of i-th worker is "Amr_i"(eg.1st worker name is ("Amr_1")

if/is even number, name of i-th worker is "sam_i"(eg.2nd worker name is ("sam_2)

age of i-th worker is = 20+(i/10%)

rate of i-th worker is =25.0-i/100

Explanation / Answer

import java.util.ArrayList;
import java.util.List;


public class TestClass {
public static void mian(String[] args)
{
List<Worker> workerList = new ArrayList<>();
  
for(int i = 0; i < 100; i++)
{
String name;
int age;
double rate;
if(i %2 == 0)
{
name = "Amr_" + String.valueOf(i);
}
else
{
name = "sam_" + String.valueOf(i);
}
age = 20+(i/10);
rate = 25.0 - i/100.0;
Worker w = new Worker(name, rate, age);
workerList.add(w);
}
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote