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
Travka [436]
4 years ago
9

Design aPayrollclass that has fields for an employee’sname, ID number, hourly pay rate,and number of hours worked. Write theappr

opriate accessor and mutator methods and a constructor that accepts theemployee’s name and ID number as arguments. The class should also have amethod that returns the employee’s gross pay, which is calculated asthenumber of hours worked multiplied by the hourly pay rate. Write anotherclass/programwithmain()methodthat demonstrates the class by creatingaPayrollobject, then asking the user to enter the data for anemployee.The program should display the amount of gross pay earn
Computers and Technology
1 answer:
wariber [46]4 years ago
5 0

Answer:

public class Payroll {

   private String employeeName;

   private int employeeId;

   private double ratePerHour;

   private double totalWorkHours;

   public Payroll(String employeeName, int employeeId) {

       this.employeeName = employeeName;

       this.employeeId = employeeId;

   }

   public String getemployeeName() {

       return employeeName;

   }

   public voemployeeId setemployeeName(String employeeName) {

       this.employeeName = employeeName;

   }

   public int getemployeeId() {

       return employeeId;

   }

   public voemployeeId setemployeeId(int employeeId) {

       this.employeeId = employeeId;

   }

   public double getratePerHour() {

       return ratePerHour;

   }

   public voemployeeId setratePerHour(double ratePerHour) {

       this.ratePerHour = ratePerHour;

   }

   public double gettotalWorkHours() {

       return totalWorkHours;

   }

   public voemployeeId settotalWorkHours(double totalWorkHours) {

       this.totalWorkHours = totalWorkHours;

   }

   public double getGrossPay() {

       return ratePerHour * totalWorkHours;

   }

}

import java.util.Scanner;

public class PayrollTest {

   public static voemployeeId main(String[] args) {

       Scanner in = new Scanner(System.in);

       String employeeName;

       int employeeId;

       System.out.print("Enter employee's Name: ");

       employeeName = in.next();

       System.out.print("Enter employee's Id: ");

       employeeId = in.nextInt();

       Payroll payroll = new Payroll(employeeName, employeeId);

       System.out.print("Enter employee's hourly rate: ");

       payroll.setratePerHour(in.nextDouble());

       System.out.print("Enter employee's total hours worked:  ");

       payroll.settotalWorkHours(in.nextDouble());

       System.out.println("Gross pay = " + payroll.getGrossPay());

   }

}

Explanation:

  • Inside the Payroll class, initialize variables for employee name, ID number, hourly pay rate, and number of hours worked.
  • Define the getter and setter methods for the necessary variables inside the Payroll class.
  • Inside the main method, create an object of the Payroll class.
  • Get all the employee information as an input from user.
  • Call the getter function of  the class and display the gross pay of employee.

You might be interested in
According to the 2010/2011 Computer Crime and Security Survey, ____ is "the most commonly seen attack, with 67.1 percent of resp
loris [4]

Answer:

Malware infection

Explanation:

Infecting computers with malware through the internet has become the most commonly seen attack according to 2010/2011 Computer Crime and Security Survey.

6 0
3 years ago
Discuss FOUR challenges that have an impact on domestic tourism
shutvik [7]
Crime rate
unemployment
fluctuations
suspension of terrorism
5 0
4 years ago
What consist(s) of a series of related instructions that tells the computer what to do and how to do it
Ber [7]

Answer:

Software program.

Explanation:

Unlike hardware which describes physical entities of a computer, a software program or simply a program (or even simply, a software) is a set of instructions or data that commands the computer on specific tasks to be performed and how they (the tasks) are performed.  Examples of a software are internet browser applications such as Google Chrome, Internet Explorer, and Mozilla Firefox and graphics applications such as Photoshop and Corel Draw.

Hope this helps!

8 0
3 years ago
Should students be able to use their phones during class
Allushta [10]
Hmm..This is a tough answer it all depends on how the students use their cell phones and if they can handle the privilege...And if they could "Sure why not" and you should monitor the students too
5 0
3 years ago
If there are 10 routers between the source and destination hosts, how many transport processes will be involved on all devices?
Gnesinka [82]

Answer:

c. 2

Explanation:

As the routers are only involved with the process of finding the best route to reach an IP address (the destination hosts), they don't look at the IP Datagram payload (which includes the transport protocol header), only to IP header.

So, the only transport processes that "talk"each other, are the one on the source host (defining TCP or UDP source port/s, and the other  on the destination host (defining TCP or UDP destination port/s), so two applications (or more) in both machines can exchange data.

5 0
3 years ago
Other questions:
  • The mouse and keyboard are also sometimes called
    5·1 answer
  • Convot the following biliary number into decimal form using any method ? (1010.100)2
    8·1 answer
  • To change the caption for a field in a query, click the field in the design grid, click the ____ button on the Design tab, click
    14·1 answer
  • Is using abbreviations and symbols in social media a problem? Why or why not?
    11·1 answer
  • What appears in the document after you have inserted a video?
    14·2 answers
  • Martha wants to create an image for her Web site. Martha should use _____.
    15·2 answers
  • Create an array using the makeRandomArray method, then take a start time using System.currentTimeMillis(). Next, run the array t
    13·1 answer
  • What is 3x10? PLZZZZZ
    11·1 answer
  • The essential idea behind digital cite zen shop is that ____.
    11·1 answer
  • During the POST process, the BIOS uses two (2) different ways to notify you of a problem, Error beep codes and error messages, e
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!