Question

JAVA Programming . Description: For an unknown number of employees: prompt and receive payroll data; calculate...

JAVA Programming .

Description:

For an unknown number of employees: prompt and receive payroll data; calculate gross pay, taxes owed, and net pay; and display a pay stub.

Input :

Prompt and receive input from the user for the following: 

/// Employee’s First and Last Name 

/// Hours Worked 

/// Pay Rate 

/// Overtime Rate Multiplier

** For the Employee’s First and Last Name:  Both data items must be read in one prompting into one variable (e.g. “Sam Jones”).  Validate to only allow alphabetic characters.  Do not validate for upper/lower case.  Re-prompt the user until the input is valid.

** For Hours Worked:  Represents the hours worked in one week.  Validate to only allow numbers in the range 0 – 100.00  Allow for up to two decimal places (e.g. 40.75).  Round to nearest cent if the user enters more than two decimal places.  Re-prompt the user until the input is valid.

** For Pay Rate:  Represents the amount earned per one hour of work.  Validate to only allow numbers in the range 9.00 – 25.00 or blank (not given).  Allow for up to two decimal places (e.g. 10.50).  Round to nearest cent if the user enters more than two decimal places.  Default value is 9.00  Dollar sign should not be entered by the user.  Re-prompt the user until the input is valid.

** For Overtime Rate Multiplier:  Represents a Pay Rate Multiplier.  Must be >= 1.0 or blank (not given).  Allow for one decimal place (e.g. 1.5).  Round if the user enters more than one decimal place.  Default value is no pay rate increase for hours > 40. In other words, hours > 40 earn wages at the same pay rate as hours <= 40. Another way of thinking of it is an overtime rate multiplier of 1.  Re-prompt the user until the input is valid. 2 v2.0 Use a While or Do-While Loop to continue prompting for employee data until a sentinel value is detected. You may not use a For-Loop. I leave the sentinel value implementation details for you to decide.

Processing:

Calculate Gross Pay as follows: 

/// Gross Pay = Hours Worked * Pay Rate 

/// If Pay Rate is not supplied, then use the default value.

/// if OverTime Multiplier is not supplied, then Gross Pay = Hours Worked * Pay Rate.

/// if OverTime Multiplier is supplied, the Gross Pay = Hours Worked (<= 40) * Pay Rate + Hours Worked (> 40) * Pay Rate * OverTime Multiplier

/// Calculate Taxes as follows:  Taxes = Gross Pay * Tax Rate 

Use the following Tax Rate Table:

Gross Pay:    Tax Rate:

<= $520    10%

> $520 and <= $680    15%

> $680 and <= $840 20%

> $840 25%

/// Calculate Net Pay as follows:  Net Pay = Gross Pay – Taxes .

Output :

After prompting, receiving and processing the data items, display the employee’s name, Gross Pay, Taxes owed, and Net Pay.

For Employee’s Name, format as proper case with only one space between the first and last names.

For Taxes, display the appropriate percentage based upon the Tax Rate Table after the word “Taxes” in the output results; for example, Taxes (15%).

Monetary values must be rounded to the nearest cent using standard rounding rules. For example, $3.409 will displayed as $3.41. $3.404 will displayed as $3.40.

Monetary values must display the dollar sign directly next to the monetary value (e.g. $304.50).

Note:

to do this, you will need to: 

Import the java.text.NumberFormat class 

Use the NumberFormat.getCurrencyInstance() method 

Use the format() method 

Do a little research for this Monetary values must be right justified.

Each employee’s information must be separated by a line of asterisks.

//// Write the following methods exactly as shown using the listed method and variable names. Method getGross is overloaded and overloading is required. Name Purpose Return Type Return Value Parameters getGross To calculate the Gross Pay using workHours and default payRate double Amount of Gross Pay double workHours getGross To calculate the Gross Pay using workHours and payRate double Amount of Gross Pay double workHours, double payRate getGross To calculate the Gross Pay using workHours and payRate; using overTimeMultiplier if applicable double Amount of Gross Pay double workHours, double payRate, double overTimeMultiplier getTaxes To calculate the Taxes using grossPay double Amount of Taxes double grossPay getNet To calculate the Net Pay using grossPay and taxes double Amount of Net Pay double grossPay, double taxes printPayStub To display the Pay Stub data Void None String empName, double grossPay, double taxes, double netPay .

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Hello students i'm writing programming code for java how to calculate gross salary of any employee

import java.until.scanner

class employeesalary

{

public static void main(string args[ ])

{

float basic_salary,da,hra,da1,hra1,grosspayment;

scanner scan=new scanner(system.in);

system.out.printin("enter basic salary of employee: ");

basic_salary=scan.nextfloat();

system.out.printin("enter basic da of employee: ");

da1=scan.nextfloat();

system.out.printin("enter basic HRA of employee: ");

hra1=scan.nextfloat();

da=(da1 *basic_salary) / 100;

hra=(hra1 * basic_salary) / 100;

grosspayment = basic_salary+da+hra;

system.out.printin("gross salary of employee: "+gross payment ");

}

}

Add a comment
Know the answer?
Add Answer to:
JAVA Programming . Description: For an unknown number of employees: prompt and receive payroll data; calculate...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT