Question

In: Computer Science

6) Create the following in a Java Program: Create payroll system Prompt the user to enter...

6) Create the following in a Java Program:


Create payroll system
Prompt the user to enter payroll information
Employee name and create variable for scanner
Hours worked
Hourly pay rate
Federal tax rate
State tax rate
Declare variable doubles for gross pay, federal, state and total deduction

Display payroll statement example:
Name of employee
Hours worked
Hourly pay rate
Gross pay which is equal hours worked multiply hourly pay rate
Federal withholding which is equal of gross pay multiply federal tax rate
State withholdings which is equal of gross pay multiply by state tax rate
Total deduction which is equal of federal + state
Net pay which where gross pay is minus total deduction

Solutions

Expert Solution

Below is the code in java with the output for the required task:

import java.util.Scanner;
 
public class Main
{
    public static void main(String args[])
    {
        
        int i;
        float sum=0;
        float average, percentage;
        Scanner scan = new Scanner(System.in);
                
                System.out.print("Name of the employee: ");  
        String name= scan.nextLine(); 
        
        System.out.print("Hours Worked: ");  
        int hours = scan.nextInt();
        
        System.out.print("Hourly pay rate: ");  
        int payr = scan.nextInt();
        
        System.out.print("Federal tax rate: ");  
        int ftax = scan.nextInt();
        
        System.out.print("State tax rate: ");  
        int stax = scan.nextInt();
        
        double gpay,fpay,spay,totald,net;
        
        gpay=hours*payr;
        fpay=gpay*ftax;
        spay=gpay*stax;
        totald=fpay+spay;
        net=totald-gpay;
        
                System.out.print("\nName of the employee: " +name);
                System.out.print("\nHours Worked: " +hours);
                System.out.print("\nHourly Pay Rate: " +payr);
                System.out.print("\nGross Pay" +gpay);
        System.out.print("\nFederal witholdings: " +fpay);
        System.out.print("\nState witholdings: " +spay);
        System.out.print("\nTotal deduction: " +totald);
        System.out.print("\nNet Pay: " +net);
    }
}
 

OUTPUT

Do leave an up-vote :) ask queries in comments


Related Solutions

Create in Java a program that will prompt the user to enter aweight for a...
Create in Java a program that will prompt the user to enter a weight for a patient in kilograms and that calculates both bolus and infusion rates based on weight of patient in an interactive GUI application, label it AMI Calculator. The patients weight will be the only entry from the user. Use 3999 as a standard for calculating BOLUS: To calculate the BOLUS you will multiply 60 times the weight of the patient for a total number. IF the...
Create in java a program that will prompt the user to enter a weight for a...
Create in java a program that will prompt the user to enter a weight for a patient in kilograms and that calculates infusion rates based on weight of patient in an interactive GUI application, label it HEPCALC. The patients’ weight will be the only entry from the user. To calculate the infusion rate you will multiply 12 times the weight divided by 50 for a total number. The end result will need to round up or down the whole number....
5) Create the following in a Java program Create a scanner Prompt the user to enter...
5) Create the following in a Java program Create a scanner Prompt the user to enter the name where the box of mail is shipping from and create the variable and relate to scanner Prompt the user to enter the name of destination where the box of mail will be shipped and create the variable and relate to scanner Prompt the user to enter the weight of the package and create variable to relate to scanner Calculate cost of shipping...
Answer in JAVA Write a program that would prompt the user to enter an integer. The...
Answer in JAVA Write a program that would prompt the user to enter an integer. The program then would displays a table of squares and cubes from 1 to the value entered by the user. The program should prompt the user to continue if they wish. Name your class NumberPowers.java, add header and sample output as block comments and uploaded it to this link. Use these formulas for calculating squares and cubes are: square = x * x cube =...
JAVA Write a java program that will sum all positive number. Prompt the user to enter...
JAVA Write a java program that will sum all positive number. Prompt the user to enter numbers and add all positive numbers. The program will not add negative numbers and the program will stop when you enter ‘0’.   Enter a number> 25 Enter a number> 9 Enter a number> 5 Enter a number> -3 Enter a number> 0 Sum = 39
Using Java! Write a program that ask prompt the user to enter a dollar amount as...
Using Java! Write a program that ask prompt the user to enter a dollar amount as double. Then, calculate how many quarters, dimes, nickels and pennies are in the dollar amount. For example: $2.56 = 10 quarters, 1 dime, 1 nickel and 1 cent. Print all of the values. Hint: Use Modulus operator and integer division when necessary.
Create a Java application that will prompt the user for the first name of 6 friends...
Create a Java application that will prompt the user for the first name of 6 friends in any order and store them in an array. First, output the array unsorted. Next, sort the array of friends and then output the sorted array to the screen. Be sure to clearly label the output. See the example program input and output shown below. It does not have to be exactly as shown in the example, however it gives you an idea of...
write java program that prompt the user to enter two numbers .the program display all numbers...
write java program that prompt the user to enter two numbers .the program display all numbers between that are divisible by 7 and 8 ( the program should swap the numbers in case the secone number id lower than first one please enter two integer number : 900 199 Swapping the numbers 224 280 336 392 448 504 560 616 672 728 784 840 896 i need it eclipse
write java program that prompt the user to enter two numbers .the program display all numbers...
write java program that prompt the user to enter two numbers .the program display all numbers between that are divisible by 7 and 8 ( the program should swap the numbers in case the secone number id lower than first one please enter two integer number : 900 199   Swapping the numbers 224 280 336 392 448 504 560 616 672 728 784 840 896 i need it eclipse
Create a C++ program which will prompt the user to enter a password continually until the...
Create a C++ program which will prompt the user to enter a password continually until the password passes the following tests. Password is 6 chars long Password has at least 1 number If the input does not match the tests, it will input a specific error message. "Pass must be 6 chars long." If the input is allowed, print a message saying "Correct Password Criteria."
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT