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

This exercise (3.10 form java how to program book 8th edition)~~... the question

ID: 3630030 • Letter: T

Question

This exercise (3.10 form java how to program book 8th edition)~~...
the question is:
(Employee Class) create class called employee that includes three instance variables-- a first name (type string), a last name (type string) and monthly salary (double). Provide a constructor that initialize the three instance variables. provide a set and a get method for each instance variables. if the monthly salary is not positive do set its value. write a test application named EmployeeTest that demonstrates class employee's capabilities. create two employee object and display each object's yearly salary. then give each employee a 10% raise and display each employees yearly salary again.
------------------------
please, separate the (Employee class) code and (employeeTest) codes, what I mean, to make it clear what should I write in the (Employee class) and what in the (EmployeeTest).
and the user should enter the information (the first name and last name of both employees + their salaries)
Please help me~~

Explanation / Answer

please rate - thanks

import java.util.*;
class employeeTest
{static Scanner in=new Scanner(System.in);
public static void main(String args[])
{String first,last;
double salary;
System.out.println("For first employee:");
System.out.print("Enter first name: ");
first=in.next();
System.out.print("Enter last name: ");
last=in.next();
System.out.print("Enter yearly salary: ");
salary=in.nextDouble();
employee employee1=new employee(first,last,salary);
System.out.println("For first employee:");
System.out.print("Enter first name: ");
first=in.next();
System.out.print("Enter last name: ");
last=in.next();
System.out.print("Enter yearly salary: ");
salary=in.nextDouble();
employee employee2=new employee(first,last,salary);
System.out.println("Before raise");
print(employee1);
print(employee2);
salary=employee1.getSalary()*1.1;
employee1.setSalary(salary);
salary=employee2.getSalary()*1.1;
employee2.setSalary(salary);
System.out.println("After raise");
print(employee1);
print(employee2);
System.out.println("non positive salary test");
employee employee3=new employee(first,last,-5);
}
public static void print(employee e)
{
System.out.println("Employee:"+e.getFirst()+" "+e.getLast()+"-Salary:"+e.getSalary());
}
}

---------------------------------

class employee
{
private String first;
private String last;
private double salary;
public employee(String f,String l, double s)
{ first=f;
last=l;
if(salary<=0)
    System.out.println("salary must be positive");
else
   salary=s;
}
public void setFirst(String f)
{
first=f;
}
public void setLast(String l)
{
last=l;
}
public void setSalary(double s)
{if(salary<=0)
    System.out.println("salary must be positive");
else
    salary=s;
}
public String getFirst()
{
return first;
}
public String getLast()
{
return last;
}
public double getSalary()
{
return salary;
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote