1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
a_sh-v [17]
3 years ago
7

Q3: Create a class called Employee that includes three instance variables—a first name (typeString), a last name (type String) a

nd a monthly salary (double). Provide a constructor that initializesthe three instance variables. Provide a set and a get method for each instance variable. If the monthly salary is not positive, do not set its value. {Do not write a full program, only a class}
Computers and Technology
1 answer:
ser-zykov [4K]3 years ago
5 0

Answer:

Follows are the code to the given question:

public class Employee //defining a class Employee

{

String first_name,last_name;

Double monthly_salary;

Employee(String first_name,String last_name,Double monthly_salary)

{

   this first_name=f_name// initialize value in first_name

   this last_name = l_name; // initialize value in the last_name

    this monthly_salary = m_salary; // initialize value in the monthly_salary

if (monthly_salary < 0.0)//use if to check monthly_salary is positive

           monthly_salary = 0.0;//set value 0

}

void setfirst_name (String f_name)//defining set method to store first_name

{

first_name = f_name; //holding the value of first_name

}  

public String getfirst_name ()//defining get method to return first_name

{

return first_name;//return first_name

}  

public void setlast_name (String l_name)//defining set method to store last_name

{

last_name = l_name; // holding the value of the last_name

}

public String getlast_name ()//defining get method to return last_name

{

return last_name;//return last_name

}  

public void setmonthly_salary(double m_salary)//defining set method to store monthly_salary

{

monthly_salary = m_salary; // holding the value of the monthly_salary

}

public double getmonthly_salary ()//defining get method to return monthly_salary

{

return monthly_salary;//return monthly_salary  

}

}

Explanation:

In this code, a class "Employee" is declared that defines two string variables  "first_name,last_name", and one double variable "monthly_salary". In the next step, a parameterized constructor is defined that stores the value into the variable, and use if block to check "monthly_salary" is a positive. It also uses the getter and setter method to hold and return its value.  

   

You might be interested in
Based on a kc value of 0.150 and the data table given, what are the equilibrium concentrations of xy, x, and y, respectively?
lidiya [134]

If the solution process is endothermic, then an increase in temperature usually results in an increase in solubility. Their heat of reaction is usually positive. The rest of the choices do not answer the question above.

4 0
3 years ago
He ____ is the section of a cpu core that performs arithmetic involving integers and logical operations.
Gelneren [198K]
Arithmetic/logic Unit (ALU)
3 0
3 years ago
What should you do to organize a large amount of data??
Kay [80]
Set them up from least to greatest or create a number graph with all the data.
5 0
3 years ago
CS124 PRATCTICE
Levart [38]

Answer:

b

Explanation:

6 0
3 years ago
Prove each statement using a proof by exhaustion. For every integer n such that 0 lessthanorequalto n &lt; 3, (n + 1)^2 &gt; n^3
yawa3891 [41]

Answer:

See attachment below

Explanation:

5 0
3 years ago
Other questions:
  • You discover memory is corrupted, what would be an indication of a software vs. a hardware issue?
    5·1 answer
  • Which file is used to determine which tty devices the root user is allowed to log in to?
    8·1 answer
  • Suppose your friend, who is a small business owner, wants to computerize her business functions such as accounting, payroll, and
    7·1 answer
  • What word can you spell with the letters e, e, a, m, g, t, and k?
    10·1 answer
  • What is the python code for these problems (100 points): Ask the user to enter a name. If there is an ‘a’ in the name, print a m
    8·1 answer
  • after clicking the start button on your computer screen desktop what option would you then select to examine systems components
    6·1 answer
  • Application servers are usually grouped into two types: page-based and _____ systems.
    6·1 answer
  • A file named loan.html, write an HTML document that looks similar to figure 9-7 in the textbook. Write four functions with these
    8·1 answer
  • Six security issues and six descriptions are shown below.
    11·1 answer
  • How to get the whole number of a fraction in python
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!