Right click on the BlueJ workspace and select New Class. This will require you to enter a name. Enter the word Activity1PayStub as the name. -Make sure you adhere to the Checkstyle conventions with your code. Now copy and paste the following code into the editor. import java.util.Scanner; /** * Activity1PayStub class is part of Lab 3 and * creates a simple pay stub. * * @author (your name) * @version (date) */ public class Activity1PayStub { public static final double OVERTIME_RATE = 1.5; /** * It all starts with the main method. * * @param args command-line arguments (not used) */ public static void main(String[] args) { } } (a) Declare a Java Scanner object (notice the import statement in the code above) to get user input values for the following data. Do not use the class given last week. It's time to use the real Scanner class! You will need a variable for the (single!) Scanner object, as well as variables for each of the data items below: Employee name Employee social security number (with hyphens) Regular (not overtime) hours worked (an integer) Overtime hours worked (an integer) Hourly pay rate (a decimal value) Read a value into each of the variables you created above using the Scanner object you declared. Make sure to prompt the user for each input. (Read the entire social security number, including hyphens, as one input.) Use print (not println) in your prompts, and do not include any newline characters in your arguments to print. The user must enter their response to each of your prompts on the same line as the prompt or your code will not pass the tests. See the sample run on the very last page of this document to see what the user's interactions with your code should look like. (b) Calculate the following values: Regular pay Overtime pay the overtime rate is 1.5, i.e., the overtime pay rate is 1.5 times the (regular) hourly pay rate Gross pay (total pay before taxes) Social security withholding (10% of gross pay) Federal tax (20% of gross after social security is deducted) Net pay (total after all deductions) Any tax rates or factors should be declared as constants. Constants go before the main method but inside the class. The position of OVERTIME_RATE in the code above shows the correct placement for constants. (c) After you have collected appropriate input from the user, use formatted output statements to display a pay stub that looks exactly like the following. How to achieve this is discussed below:
Right click on the BlueJ workspace and select New Class. This will require you to enter a name. Enter
the word Activity1PayStub as the name. -Make sure you adhere to the Checkstyle conventions with your code.
Now copy and paste the following code into the editor.
import java.util.Scanner;
/**
* Activity1PayStub class is part of Lab 3 and
* creates a simple pay stub.
*
* @author (your name)
* @version (date)
*/
public class Activity1PayStub
{
public static final double OVERTIME_RATE = 1.5;
/**
* It all starts with the main method.
*
* @param args command-line arguments (not used)
*/
public static void main(String[] args)
{
}
}
(a) Declare a Java Scanner object (notice the import statement in the code above) to get user input
values for the following data. Do not use the class given last week. It's time to use the real
Scanner class! You will need a variable for the (single!) Scanner object, as well as variables for
each of the data items below:
Employee name
Employee social security number (with hyphens)
Regular (not overtime) hours worked (an integer)
Overtime hours worked (an integer)
Hourly pay rate (a decimal value)
Read a value into each of the variables you created above using the Scanner object you declared.
Make sure to prompt the user for each input. (Read the entire social security number, including
hyphens, as one input.) Use print (not println) in your prompts, and do not include any newline
characters in your arguments to print. The user must enter their response to each of your prompts
on the same line as the prompt or your code will not pass the tests. See the sample run on the
very last page of this document to see what the user's interactions with your code should look
like.
(b) Calculate the following values:
Regular pay
Overtime pay the overtime rate is 1.5, i.e., the overtime pay rate is 1.5 times the (regular)
hourly pay rate
Gross pay (total pay before taxes)
Social security withholding (10% of gross pay)
Federal tax (20% of gross after social security is deducted)
Net pay (total after all deductions)
Any tax rates or factors should be declared as constants. Constants go before the main method but
inside the class. The position of OVERTIME_RATE in the code above shows the correct placement
for constants.
(c) After you have collected appropriate input from the user, use formatted output statements to
display a pay stub that looks exactly like the following. How to achieve this is discussed below:
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images