Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Payroll Program The goal of this assignment is to help you create a payroll prog

ID: 3659237 • Letter: P

Question

Payroll Program The goal of this assignment is to help you create a payroll program. Write a program that prompts the user for the following information: Name Social security number Hourly pay rate Number of hours worked Accurately created syntax in the program to display the following: All the input data Gross pay, defined as hourly pay rate times hours worked Federal withholding tax, defined as fifteen percent of the gross pay State withholding tax, defined as five percent of the gross pay Net pay, defined as gross pay minus taxes You may use the following format as reference to write the program: Command Prompt C:C#Chapter.02>Payroll Enter your name: Ruth Roberts Social Security Number: XXX-XX-XXXX Hourly pay rate: 13.50 Hours worked: 36 Payroll Summary for: Ruth Roberts SSN: XXX-XX-XXXX You earned $36.00 at $13.50 per hour Gross pay: $486.00 Federal withholding: $72.90 State withholding: $24.30 _______________________________ Net pay: $388.80 C:C#Chapter.02> Save the program as Payroll.cs. Embed the program in a Microsoft Word document with a description of your programming strategy. Cite any sources in APA format on a separate page.

Explanation / Answer

// Stores data about an employee public class Employee { //fields String name; int rate; int hours; // constructor public Employee(String name, int rate, int hours) { this.name = name; this.rate = rate; this.hours = hours; } // returns the pay: public int getPay() { return rate*hours; } // getters and setters public String getName() { return name; } public void setName(String name) { this.name = name; } public float getRate() { return rate; } public void setRate(int rate) { this.rate = rate; } public float getHours() { return hours; } public void setHours(int hours) { this.hours = hours; } import java.util.Scanner; // program uses class Scanner public class Payroll { // main method begins execution of Java application public static void main( String args[] ) { // create Scanner to obtain input from command window Scanner input = new Scanner( System.in ); String name; // employee's name int wage; // hourly rate int hours; // number of hours worked int total; // product of wage and hours System.out.print( "Enter employee's name: " ); // prompt user to input name name = input.nextLine(); //read employee's name from user's input while (!name.equals("stop")) { System.out.print( "Enter hourly wage: " ); // prompt user for employee's hourly wage hours = Integer.parseInt(input.nextLine()); // read hourly rate from user's input while (hours < 0) { // if it's negative System.out.print( "Enter hourly wage: " ); // prompt user for employee's hourly wage hours = Integer.parseInt(input.nextLine()); // read hourly rate from user's input } System.out.print( "Enter hours worked: " ); // prompt user to enter number of hours worked for the week wage = Integer.parseInt(input.nextLine()); // read number of weeks from user's input while (wage < 0) { // if it's negative System.out.print( "Enter hours worked: " ); // prompt user to enter number of hours worked for the week wage = Integer.parseInt(input.nextLine()); // read number of weeks from user's input } // make employee object Employee e = new Employee(name,wage,hours); System.out.println( "The Employee " + e.getName() ); // displays employee's name System.out.printf( "weekly pay is $%d " , e.getPay() ); // displays weekly pay System.out.println(); System.out.print( "Enter employee's name: " ); // prompt user to input name name = input.nextLine(); //read employee's name from user's input } } // end method main }
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote