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
Mademuasel [1]
2 years ago
8

Write a program that demonstrates the class by creating a Payroll object, then asking the user to enter the data for an employee

.
Computers and Technology
1 answer:
AlexFokin [52]2 years ago
8 0

Answer:

import java.util.Scanner;

public class Payroll {

   //set variable field

   private String name;

   private int idNumber;

   private double hourlyRate;

   private int hoursWorked;

   private double grossPay;

   //methods to get values of private class variables

   public String getName()

    {

        return name;

    }

   public int getIdNumber()

   {

      return idNumber;

   }

   public double getHourlyRate()

   {

       return hourlyRate;

   }

   public int getHoursWorked()

   {

       return hoursWorked;

   }

   public double getGrossPay()

   {

      return hoursWorked * hourlyRate;

   }

   //methods to initialize or change the private class values.

   public void setName( String nameGiven)

   {

       name = nameGiven;

   }

   public void setIdNumber(int idNumberGiven)

   {

       idNumber = idNumberGiven;

   }

   public void setHourlyRate(double rateGiven)

   {

       hourlyRate = rateGiven;

   }

   public void setHoursWorked(int hoursGiven)

   {

      hoursWorked = hoursGiven;

   }

   //Constructors

   public Payroll(String nameGiven, int idNumberGiven, double rateGiven, int hoursGiven)

   {

       name = nameGiven;

       idNumber = idNumberGiven;

       hourlyRate = rateGiven;

        hoursWorked = hoursGiven;

   }

 

   public static void main(String[] args)

   {

       double userGrossPay;

       String userEmplName;

       int userIdNum;

       double userRate;

       int userHours;

       Scanner scanner = new Scanner(System.in);

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

       userEmplName = scanner.nextLine();

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

       userIdNum = scanner.nextInt();

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

       userRate = scanner.nextDouble();

       System.out.print("Enter number of hours worked:");

       userHours = scanner.nextInt();

        Payroll payroll1 = new Payroll(userEmplName, userIdNum, userRate, userHours);

 

      payroll1.setName(userEmplName);

       payroll1.setIdNumber(userIdNum);

       payroll1.setHourlyRate(userRate);

       payroll1.setHoursWorked(userHours);

 

       System.out.printf(userEmplName + ", employee number " + userIdNum + ", made $%.2f in gross pay.\n", payroll1.getGrossPay());

}

}

Explanation:

The class "Payroll" is used to hold data of employees to be paid. the main function creates an instance of the class "payroll1", sets the name, id-number, hourly rate, and hours worked by the employee, then prints on screen the details of the payroll1 object.

You might be interested in
________ work(s) by using radio waves to communicate with radio antennas placed within adjacent geographic areas.
RSB [31]
Cell phones work(s) by using radio waves to communicate with radio antennas placed within adjacent geographic areas.
4 0
3 years ago
In cell h15 enter a vlookup function to determine the 2018 percentage of total attendance for the city listed in cell h14. Use t
Amanda [17]

Answer:

=vlookup(h14, a5:h11,8,false)

Explanation:

Here, h15 is the cell in which we need the output and the value to be matched in rows to find the exact row is h14, and the range is expressed as a5:h11. Now to find the column number, we need to figure out the first and the concerned column. So, the concerned column is in which the total attendance is being listed and it is h(h14), and the first column is a. So, the column number is a=1 h=8, =8. And since we need the exact match, the value of the fourth argument is false. And thus, we have the above formula. Remember. vlookup formula is:

=vlookup(cell where the result is to be placed, range, column number in the same row as h14, exact match or approximate match). For exact match it's false, and for the approximate match, it's true.

8 0
3 years ago
ASAP PLS HELP: I’ll give brainliest if you u answer them all correctly!!
ra1l [238]

Answer:

1 c

2 a

3 c

4 b

5 c

6 b

7 d

8 a

9 d

10 b

6 0
3 years ago
Read 2 more answers
Point mode allows you to select cells for use in a formula by using your finger or the pointer
Serga [27]
That statement is true

in excel, you could enter point mode by pressing any keyboard navigation such as page down, page up, or the arrow keys or by clicking any cells in the worksheet

This mode will select a cell or range as formula operand


7 0
2 years ago
What is the price of a k1 speed birthday party?
valentinak56 [21]
There is differen prices depending on the race go to the k1 website to see the packages
8 0
3 years ago
Read 2 more answers
Other questions:
  • Two electronics students are discussing static electricity and electric current. Student A says that a basic property of static
    12·1 answer
  • What is the f(n) runtime of the following pseudocode: sum-0 for A = N/2 downto 1 for B-1 t increment sum by B Explain: exactly w
    13·1 answer
  • You can execute three main types of linux commands. what are they?
    8·1 answer
  • A machine is classified as a compound machine if it?
    8·2 answers
  • Create the Following Menu in a loop so the menu will continually show until the user chooses to exit.AddMultiplyExitAdd a value
    10·1 answer
  • What type of diagram will you find nodes?
    15·1 answer
  • Anyone understand coding? Please Help! Thank you! :)
    8·1 answer
  • write a program that calculates the total grade for N classroom exerices as a perfentage. the user should input the value for N
    11·1 answer
  • Which expression is equivalent to 3x + 3x + 3x?<br><br> From Performance Matters
    11·2 answers
  • Liquid-liquid extraction is best suited to separate a mixture of compounds when:
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!