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

In this lab, you complete a Java program provided with the data files for this b

ID: 3528194 • Letter: I

Question

In this lab, you complete a Java program provided with the data files for this book. The program calculates the amount of tax withheld from an employee's weekly salary, the tac deduction to which the employee is entitled for each dependent, and the employee's take-home pay. The program output includes state tax withheld, federal tax withheld, dependent tax deductions, salary, and take-home pay. 1. Open the source code file named Payroll.java 2. Variables have been declared and initialized for you as needed, and the output statements have been written. Read the code carefully before you proceed to the next step. 3. Write the java code needed to perform the following: - Calculate state withholding tax at 6.0%, and calculate federal withholding tax at 25%. - Calculate dependent deductions at 2.0% of the employee's salary for each dependent. - Calculate total withholding. - Calculate take-home pay as salary minus total withholding plus deductions. 4. Save this source code file in a directory of your choice, and then make that directory your working directory. 5. Compile the program. 6. Execute the program. You should get the following output: - State Tax: $75.0 - Federal Tax: $312.0 - Dependents: $50.0 - Salary: $1250.0 - Take-Home Pay: $912.5 7. In this program, the variables named salary and numDependents are initialized with the value 1250.0 and 2. To make this program more flexible, modify it to accept interactive input for salary and numDependents. Name the modified version Payroll2.java I NEED HELP PLEASEEEE! thank you so much.

Explanation / Answer

import java.util.Scanner; // for the Scanner class 002 003 /** 004 This program calculates the employee wages minus taxes and medical 005 deductions. 006 */ 007 008 public class ProjectB 009 { 010 public static void main(String[] args) 011 { 012 double grossPay; // To hold gross pay 013 double taxablePay; // To hold taxable pay 014 double federalTax; // To hold federal tax 015 double net; // To hold net pay 016 String stop = ("x"); // To stop program 017 018 // get the gross pay. 019 grossPay = getGross(); 020 021 // get the taxable pay. 022 taxablePay = getTaxablePay(grossPay); 023 024 // get the federal tax. 025 federalTax = taxxP(grossPay, taxablePay); 026 027 // get the net pay. 028 net = netP(taxablePay, federalTax); 029 030 // display results 031 displayResults(grossPay, federalTax, taxablePay, net); 032 033 // stop program 034 if (stop == ("x")) 035 { 036 Scanner keyboard = new Scanner(System.in); 037 System.out.print("Enter x to stop "); 038 stop = keyboard.nextLine(); 039 040 } 041 else 042 { 043 grossPay = getGross(); 044 } 045 } 046 047 /** 048 The getGross method prompts the user 049 to enter info to get the gross pay. 050 @return info and gross pay. 051 */ 052 053 public static double getGross() 054 { 055 String name; // hold name input 056 double hours; // hold hours worked 057 double payRate; // hold pay rate 058 double overTime; // hold overtime 059 double overTimeHours; // hold overtime hours 060 Scanner keyboard = new Scanner(System.in); 061 System.out.print("What is your name? "); 062 name = keyboard.nextLine(); 063 System.out.print("How many hours did you work this week? "); 064 hours = keyboard.nextDouble(); 065 System.out.print("What is your pay rate? "); 066 payRate = keyboard.nextDouble(); 067 068 if (hours > 40) 069 { 070 overTimeHours = (hours - 40); 071 overTime = overTimeHours * payRate * 1.5; 072 return (hours - overTimeHours) * payRate + overTime; 073 } 074 else 075 { 076 return (hours * payRate); 077 } 078 } 079 080 /** 081 The getTaxablePay prompt the user to enter 082 info to display and calculates tax. 083 @param grossPay the gross pay. 084 @return the tax amount. 085 */ 086 087 public static double getTaxablePay(double grossPay) 088 { 089 double taxPay; 090 int dependents; 091 String maritalStatus; 092 double Tax; 093 String healthcare; 094 095 Scanner keyboard = new Scanner(System.in); 096 System.out.print("What is you marital status?(married = M, single = S) "); 097 maritalStatus = keyboard.nextLine(); 098 System.out.print("How many dependents do you have? "); 099 dependents = keyboard.nextInt(); 100 System.out.print("Do you have healthcare?(yes = Y, no = N) "); 101 healthcare = keyboard.nextLine(); 102 keyboard.nextLine(); 103 104 if (maritalStatus == ("M")) 105 { 106 taxPay = grossPay - 150 - 70.0 * dependents; 107 108 if (healthcare == ("Y")) 109 { 110 taxPay = taxPay - 100; 111 return taxPay; 112 } 113 114 if (taxPay > 800) 115 { 116 Tax = (taxPay - 800) * .35 + (800 - 500) * .25 + (500 - 200) * .15 +200 * .10; 117 return Tax; 118 } 119 else if (taxPay > 500) 120 { 121 Tax = (taxPay - 500) * .25 + (500 - 200) * .15 +200 * .10; 122 return Tax; 123 } 124 else if (taxPay > 200) 125 { 126 Tax = (taxPay - 200) * .15 +200 * .10; 127 return Tax; 128 } 129 else 130 { 131 Tax = taxPay * .10; 132 return Tax; 133 } 134 } 135 else 136 { 137 taxPay = grossPay - 75 - 70.0 * dependents; 138 139 if (healthcare == ("Y")) 140 { 141 taxPay = taxPay - 60; 142 } 143 if (taxPay > 400) 144 { 145 Tax = (taxPay - 400) * .35 + (400 - 250) * .25 + (250 - 100) * .15 +100 * .10; 146 } 147 else if (taxPay > 250) 148 { 149 Tax = (taxPay - 250) * .25 + (250 - 100) * .15 +100 * .10; 150 } 151 else if (taxPay > 100) 152 { 153 Tax = (taxPay - 100) * .15 +100 * .10; 154 } 155 else 156 { 157 Tax = taxPay * .10; 158 } 159 } 160 return Tax; 161 } 162 163 /** 164 The taxxP method converts the taxable pay. 165 @param grossPay 166 @param taxable pay 167 @return tax 168 */ 169 170 public static double taxxP(double grossPay, double taxablePay) 171 { 172 return (grossPay - taxablePay); 173 } 174 175 /** 176 The netP method calculates and get the net pay. 177 @param taxablePay 178 @param federalTax 179 @return net pay 180 */ 181 182 public static double netP(double taxablePay, double federalTax) 183 { 184 return (federalTax - taxablePay); 185 } 186 187 /** 188 The displayResults method displays a message 189 showing the results. 190 @param grossPay 191 @param federalPay 192 @param taxablePay 193 @param net. 194 */ 195 196 public static void displayResults(double grossPay, double federalTax, double taxablePay, double net) 197 { 198 System.out.println("Gross pay is " + grossPay); 199 System.out.println("Taxable pay is " + federalTax); 200 System.out.println("Tax is " + taxablePay); 201 System.out.println("Your net pay is " + net); 202 } 203 } 204

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