Question

Java please At this point in your life most of you have or have had a...

Java please

At this point in your life most of you have or have had a job. One of the aspects of a job is dealing with taxes. Benjamin Franklin said “in this world nothing can be said to be certain, except death and taxes.” There are many types of taxes. Some of the most familiar taxes are state sales tax, federal and state income tax and local property tax. Write a program that will compute and print the federal, state, and local taxes for three workers of the ABC Company and print out the company totals.
Example input:
First name​// Jim
Last name​// Jackson
Number of dependents ​// 3
Hourly rate​// 14.50
Number of hours worked​// 55.50
Local tax withheld to date​// 515.00
Federal tax withheld to date​// 6010.00
Sate tax withheld to date​// 2163.00
The calculations will be as follows:
1) Local tax is 1.15% of the first $45,000 earned.
2) Federal tax withheld is computed by taking gross pay per pay period minus $15.00 for each dependent times 10% of yearly income projected to be between 0 and $20,000, 20% of yearly income projected to be between $20,000 and $40,000, and 30% on yearly income projected to be over $40,000.
3) State tax withheld is 5% of projected income between 0 and $30, 000, and 10% over $30,000.
4) Over-time is computed as time-and-a-half over 40 hours per week.
5) GrossWages: the employee gets time and a half for hours worked over 40.
6) CurrentFederalTax starts with the GrossWages minus the number of dependence times $15.00. In Jim Jackson’s case this is $917.13 – 45 which is $872.13. This number is multiplied by 52 to give $45,350.13 which is the projected yearly income upon which the CurrentFederalTax is based. This number is over $40,000 and puts Jim Jackson in the 30% bracket. We multiply $872.13 by 30% to give us the CurrentFederalTax of $261.64.
7) The maximum local tax is $517.50 which is 1.15% of $45,000. The input indicates that Jim Jackson has made almost that since the local tax withheld to date is $515.00. 1.15% of $917.13 is $10.54. Since the sum of $515.00 and $10.54 is greater than the maximum of $517.50, Jim Jackson only needs to pay $2.50 which is the amount to bring him up to the maximum $517.50.
Using the above data, typical outputs for one employee will look like: (this is computed accurately)
Worker:​Tom Smith
One week:​​55.50
Amount per hour:​$14.50
​Total for one week​$917.13
​ ​Current​Yr. To Date
​Federal​$261.64​$6271.64
​State​$91.71​$2254.71
​Local​$2.50​$517.50
​Total Deductions​$355.85
​Net Pay​$561.28
Output for the employer report would look like this: // (these are not correct data)
The ABCD Company
Weekly summery
​ ​​Current​Yr. To Date
​Federal​​$5,313.43​$78,1678.66
​State​​$1,112.12​$41,233.33
​Local​​$230.40​$7,322.33
​Total Deductions​​$2,787.05​$134,830.08​
Gross Wages​$134,317.13​
​Net Pay​$72,830.08​
Project 3 will have at least three classes. Create a worker class which will have methods and data related to a single worker. Keep in mind the requirements for project 5. Keep all input and output in centralized methods that can be easily modified. Create an Employer class that will have data and methods associated with the employer. Again, keep in mind the requirements for project 6. Keep all input and output in separate methods that can be easily modified. Using the examples below as your guide, print the answer numbers with dollar signs. You must use the following demo program.
import java.util.Scanner;
public class WorkerDemo
{
​static Scanner scan = new Scanner(System.in);
​public static void main(String[] args)
​{
​Employer clerk = new Employer ( );
​Worker worker;
​int count;
​System.out.println("Enter number of employees:");
​int numberOfWorkers = scan.nextInt();
​for (count = 1; count <= numberOfWorkers; count++)
​{
​worker = new Worker ();
​System.out.println("Enter data for worker number " + count);
​worker.readInput();
​worker.calculateData();
​worker.writeOutput( );
​clerk.colectDataForEmployerReport(employee);
​}
​clerk.printDataForEmployerReport();
​}
} the calculateData() method must have 4 private methods to:
// 1) calculate income
// 2) calculate federal tax
// 3) calculate state tax
// 4) calculate local tax
// Getters and Setters for the private data are necessary. Eclipse will
// create them for you. Place your mouse where you would like them
// (Usually at the bottom of the class). Right click, choose Source,
// choose Generate Getters and Setters. Choose the private variables you
// want. (all of them).
public class OutPut // On my website is class OutPut that can be used to print one line of output. There are
two static methods that can be used to print a string left or right justified in a space of
characters and two static methods that will return a string left or right justified in a space of characters.
See my website.
// two ways to do money formatting
import java.text.DecimalFormat;
import java.text.NumberFormat;
public class MoenyFormatDemo
{
​public static void main(String[] args)
​{
​NumberFormat moneyFormatter = NumberFormat.getCurrencyInstance();
​System.out.println(moneyFormatter.format(2003.4));
​String money = moneyFormatter.format(20043.44);
​System.out.println(money);
​DecimalFormat dollarFormat = new DecimalFormat("$#,###,###.00");
​System.out.println(dollarFormat.format(34456.2));
​money = dollarFormat.format(20043.44);
​System.out.println(money);
​}
}
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Hi,

The following question has been answered according to the HomeworkLib's guidelines in case of any queries you can ask me in comments.

//employe.java

import java.text.NumberFormat;
import java.util.ArrayList;
public class employee {
private ArrayList<String> firstname,lastname;
private ArrayList<Integer> dependent;
private ArrayList<Float> rate,hrs,localTax,fedTax,stateTax,grossWages,currFedTax,currLocalTax,currStateTax,totalTax,totalDed,netPay;

public employee(){
firstname = new ArrayList<String>();
lastname = new ArrayList<String>();
dependent = new ArrayList<Integer>();
rate = new ArrayList<Float>();
hrs = new ArrayList<Float>();
localTax = new ArrayList<Float>();
fedTax = new ArrayList<Float>();
stateTax = new ArrayList<Float>();
grossWages = new ArrayList<Float>();
currLocalTax = new ArrayList<Float>();
currFedTax = new ArrayList<Float>();
currStateTax = new ArrayList<Float>();
totalTax = new ArrayList<Float>();
totalDed = new ArrayList<Float>();
netPay = new ArrayList<Float>();
}
public ArrayList<String> getFname() {
return firstname;
}

public void setFname(ArrayList<String> firstname) {
this.firstname = firstname;
}
public ArrayList<String> getLname() {
return lastname;
}
public void setLname(ArrayList<String> lastname) {
this.lastname = lastname;
}
public ArrayList<Integer> getDependent() {
return dependent;
}
public void setDependent(ArrayList<Integer> dependent) {
this.dependent = dependent;
}
public ArrayList<Float> getHourly_rate() {
return rate;
}
public void setHourly_rate(ArrayList<Float> rate) {
this.rate = rate;
}
public ArrayList<Float> getNo_of_hours() {
return hrs;
}
public void setNo_of_hours(ArrayList<Float> hrs) {
this.hrs = hrs;
}
public ArrayList<Float> getL_tax() {
return localTax;
}
public void setL_tax(ArrayList<Float> localTax) {
this.localTax = localTax;
}
public ArrayList<Float> getF_tax() {
return fedTax;
}
public void setF_tax(ArrayList<Float> fedTax) {
this.fedTax = fedTax;
}
public ArrayList<Float> getS_tax() {
return stateTax;
}
public void setS_tax(ArrayList<Float> stateTax) {
this.stateTax = stateTax;
}
public ArrayList<Float> getG_wages() {
return grossWages;
}
public void setG_wages(ArrayList<Float> grossWages) {
this.grossWages = grossWages;
}
public ArrayList<Float> getCf_tax() {
return currFedTax;
}
public void setCf_tax(ArrayList<Float> currFedTax) {
this.currFedTax = currFedTax;
}
public ArrayList<Float> getCl_tax() {
return currLocalTax;
}
public void setCl_tax(ArrayList<Float> currLocalTax) {
this.currLocalTax = currLocalTax;
}
public ArrayList<Float> getCs_tax() {
return currStateTax;
}
public void setCs_tax(ArrayList<Float> currStateTax) {
this.currStateTax = currStateTax;
}
public ArrayList<Float> getT_tax() {
return totalTax;
}
public void setT_tax(ArrayList<Float> totalTax) {
this.totalTax = totalTax;
}
public ArrayList<Float> getCt_tax() {
return totalDed;
}
public void setCt_tax(ArrayList<Float> totalDed) {
this.totalDed = totalDed;
}
public ArrayList<Float> getNet_pay() {
return netPay;
}
public void setNet_pay(ArrayList<Float> netPay) {
this.netPay = netPay;
}
public void readInput(String firstName2, String lastName2, int dependent2,
float rate2, float hrs2, float localTax2, float fedTax2, float stateTax2){
this.firstname.add(firstName2);
this.lastname.add(lastName2);
this.dependent.add(dependent2);
this.rate.add(rate2);
this.hrs.add(hrs2);
this.localTax.add(localTax2);
this.fedTax.add(fedTax2);
this.stateTax.add(stateTax2);
}
  
public void writeOutput(int i){
NumberFormat formatter = NumberFormat.getCurrencyInstance();
System.out.println("Employee: " + firstname.get(i) + " " + lastname.get(i));
String moneyString = formatter.format(hrs.get(i));
String moneyString1 = formatter.format(rate.get(i));
System.out.println("Hours Worked: " + moneyString);
System.out.println("Hourly Rate: " + moneyString1);
moneyString = formatter.format(grossWages.get(i));
System.out.println("Gross Wages: " + moneyString);
System.out.println("Current Yr. To Date");
moneyString = formatter.format(currFedTax.get(i));
moneyString1 = formatter.format(fedTax.get(i));
System.out.println("Federal " + moneyString+ " " +moneyString1);
moneyString = formatter.format(currLocalTax.get(i));
moneyString1 = formatter.format(localTax.get(i));
System.out.println("Local " + moneyString + " " + moneyString1);
moneyString = formatter.format(totalDed.get(i));
System.out.println("Total Deductions " + moneyString);
moneyString = formatter.format(netPay.get(i));
System.out.println("Net Pay " + moneyString);
moneyString = formatter.format(currStateTax.get(i));
moneyString1 = formatter.format(stateTax.get(i));
System.out.println("State " + moneyString+ " " + moneyString1);
System.out.println("\n\n");
}
public void calculateData(int i) {

float fedTax,g_pay,temp,annual_pay,tax_percent,localTax,temp2,stateTax,fedTax1,stateTax1,localTax1,totalTax;
g_pay = this.rate.get(i) * this.hrs.get(i);
temp = g_pay - (15 * this.dependent.get(i));
annual_pay = temp * 52;
if(annual_pay > 40000)
tax_percent = 0.3f;
else if(annual_pay > 20000 && annual_pay < 40000)
tax_percent = 0.2f;
else
tax_percent = 0.1f;
fedTax = temp * tax_percent;
localTax = (float) (g_pay * 0.0115);
temp2 = this.localTax.get(i) + localTax;
if(temp2 > 517.50){
localTax = (float) (517.50 - this.localTax.get(i));
}

if(annual_pay > 30000)
tax_percent = 0.1f;
else
tax_percent = 0.05f;
stateTax = temp * tax_percent;
fedTax1 = this.fedTax.get(i);
stateTax1 = this.stateTax.get(i);
localTax1 = this.localTax.get(i);
this.grossWages.add(g_pay);
this.currFedTax.add(fedTax);
this.currLocalTax.add(localTax);
this.currStateTax.add(stateTax);
this.stateTax.add(stateTax);
this.fedTax.set(i, (fedTax + fedTax1));
this.stateTax.set(i, (stateTax + stateTax1));
this.localTax.set(i, (localTax + localTax1));
this.totalDed.add(fedTax + localTax + stateTax);
this.netPay.add(g_pay - (fedTax + localTax + stateTax));
totalTax = this.stateTax.get(i) + this.fedTax.get(i) + this.localTax.get(i);
this.totalTax.add(totalTax);
}
}

demo.java

package demo;

import java.util.Scanner;
public class demo
{
static Scanner sc = new Scanner(System.in);
public static void main(String[] args)
{
company testCompany = new company( );
employee testEmployee = new employee();
int count,dependent;
String firstName,lastName;
float hourlyRate,noOfHours,lTax,f_tax,s_tax;
System.out.println("Enter number of employees:");
int numberOfEmployees = sc.nextInt();
for (count = 0; count < numberOfEmployees; count++)
{
System.out.println("Enter data for employee number " + count);
System.out.println("First Name ");
firstName = sc.next();
System.out.println("Last Name ");
lastName = sc.next();
System.out.println("Number of dependents ");
dependent = sc.nextInt();
System.out.println("Hourly rate ");
hourlyRate = sc.nextFloat();
System.out.println("Number of hours worked ");
noOfHours = sc.nextFloat();
System.out.println("Local tax withheld to date ");
lTax = sc.nextFloat();
System.out.println("Federal tax withheld to date ");
f_tax = sc.nextFloat();
System.out.println("State tax withheld to date ");
s_tax = sc.nextFloat();
testEmployee.readInput(firstName,lastName,dependent,hourlyRate,noOfHours,lTax,f_tax,s_tax);
testEmployee.calculateData(count);
testEmployee.writeOutput(count);
testCompany.collectData(testEmployee,count);
}
testCompany.printData();
}
}

compan.java


import java.text.NumberFormat;
public class company
{
private float fedTax,stateTax,grossWages,netPay,currFedTax,currStateTax,totalDed;
public float getF_tax()
{
return fedTax;
}
public float getS_tax() {
return stateTax;
}
public float getG_wages() {
return grossWages;
}
public float getNet_pay() {
return netPay;
}
public float getCf_tax() {
return currFedTax;
}
public float getCs_tax() {
return currStateTax;
}
public float getCt_deduction() {
return totalDed;
}
public void collectData(employee emp, int count)
{
System.out.println(count);
for(int j=0 ; j<=count ; j++)
{
fedTax = fedTax + emp.getF_tax().get(j);
currFedTax=currFedTax+emp.getCf_tax().get(j);
currStateTax=currStateTax+emp.getCs_tax().get(j);
totalDed=totalDed+emp.getCt_tax().get(j);
stateTax = stateTax + emp.getS_tax().get(j);
grossWages = grossWages + emp.getG_wages().get(j);
netPay = netPay + emp.getNet_pay().get(j);
}
}
public void printData()
{
System.out.println("\n\nCurrent Yr. To Date");
NumberFormat formatter = NumberFormat.getCurrencyInstance();
String moneyString = formatter.format(getCf_tax());
System.out.println("Federal " + moneyString + " $" + getF_tax());
moneyString = formatter.format(getCs_tax());
String moneyString1 = formatter.format(getS_tax());
System.out.println("State" + moneyString + " $" + moneyString1);
moneyString = formatter.format(getCt_deduction());
System.out.println("Total Deductions $" + moneyString );
moneyString = formatter.format(getG_wages());
System.out.println("Gross Wages " + moneyString);
moneyString = formatter.format(getNet_pay());
System.out.println("Net pay " + moneyString);
}
}

OUTPUT

Add a comment
Know the answer?
Add Answer to:
Java please At this point in your life most of you have or have had a...
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
  • please edit my java code perferably on jgrasp version 50.0 , wont complie correctly :( the...

    please edit my java code perferably on jgrasp version 50.0 , wont complie correctly :( the program is supposed to read from my input file and do the following        1) print out the original data in the file without doing anything to it.        2) an ordered list of all students names (last names) alphabetically and the average GPA of all student togther . 3) freshman list in alphabeticalorder by last name with the average GPA of the freshmen...

  • ******** IN JAVA ********* I have a program that I need help debugging. This program should...

    ******** IN JAVA ********* I have a program that I need help debugging. This program should ask a user to input 3 dimensions of a rectangular block (length, width, and height), and then perform a volume and surface area calculation and display the results of both. It should only be done using local variables via methods and should have 4 methods: getInput, volBlock, saBlock, and display (should be void). I have most of it written here: import java.util.*; public class...

  • Java Questions When creating a for loop, which statement will correctly initialize more than one variable?...

    Java Questions When creating a for loop, which statement will correctly initialize more than one variable? a. for a=1, b=2 c. for(a=1, b=2) b. for(a=1; b=2) d. for(a = 1&& b = 2) A method employee() is returning a double value. Which of the following is the correct way of defining this method? public double employee()                                    c. public int employee() public double employee(int t)                  d. public void employee() The ____ statement is useful when you need to test a...

  • Please help me do the java project For this project you will be reading in a...

    Please help me do the java project For this project you will be reading in a text file and evaluating it in order to create a new file that represents the Class that will represent the properties of the text file. For example, consider the following text file: students.txt ID              Name                              Age                    IsMale           GPA 1                Tom Ryan                       22                       True              3.1 2                Jack Peterson                31                       True              2.7 3                Cindy LuWho                12                       False             3.9 When you read in the header line, you...

  • [Java] Please test your code in the link I provide before you post your answer. The...

    [Java] Please test your code in the link I provide before you post your answer. The output should be looked like exact same as the tester. http://www.codecheck.it/files/17033122188mcxvjz8n8qbk0k9fyfrd3w95 Use the following file: LinkedListUtilTester.java import java.util.LinkedList; public class LinkedListUtilTester { public static void main(String[] args) { LinkedList<String> list = new LinkedList<>(); list.add("1"); list.add("2"); list.add("3"); list.add("4"); list.add("5"); list.add("6"); list.add("7"); list.add("8"); list.add("9"); list.add("10"); list.add("11"); list.add("12"); list.add("13"); list.add("14"); list.add("15"); LinkedListUtil.shrink(list, 3); System.out.println(list); System.out.println("Expected: [1, 2, 4, 5, 7, 8, 10, 11, 13, 14]"); System.out.println(LinkedListUtil.reverse(list)); System.out.println("Expected:...

  • java This lab is intended to give you practice creating a class with a constructor method,...

    java This lab is intended to give you practice creating a class with a constructor method, accessor methods, mutator methods, equals method , toString method and a equals method. In this lab you need to create two separate classes, one Student class and other Lab10 class. You need to define your instance variables, accessor methods, mutator methods, constructor, toString method and equals method in Student class. You need to create objects in Lab10 class which will have your main method...

  • [Java] Please test your code in the link I provide before you post your answer. The...

    [Java] Please test your code in the link I provide before you post your answer. The output should be looked like exact same as the tester. http://www.codecheck.it/files/17050415451csldwjahxt2kwn73ahd6vukt Thank you. Write a simplified application to illustrate the use of an undo button for a word processor. It keeps a history of all items and allows the user to undo the last. Write a class UndoStack. Implement using a Stack of Strings. The constructor will create an empty Stack to keep the...

  • JAVA you have been given the code for Node Class (that holds Strings) and the LinkedList...

    JAVA you have been given the code for Node Class (that holds Strings) and the LinkedList Class (some methods included). Remember, you will use the LinkedList Class that we developed in class not Java’s LinkedList Class. You will add the following method to the LinkedList Class: printEvenNodes – this is a void method that prints Nodes that have even indices (e.g., 0, 2, 4, etc). Create a LinkedListDemo class. Use a Scanner Class to read in city names and store...

  • JAVA LANG PLEASE: I have follwed these below guidelines but when i run my queue test...

    JAVA LANG PLEASE: I have follwed these below guidelines but when i run my queue test it is not executing but my stack is working fine, can you fix it please! MyQueue.java Implement a queue using the MyStack.java implementation as your data structure.  In other words, your instance variable to hold the queue items will be a MyStack class. enqueue(String item): inserts item into the queue dequeue(): returns and deletes the first element in the queue isEmpty(): returns true or false...

  • My Java code from last assignment: Previous Java code: public static void main(String args[]) { //...

    My Java code from last assignment: Previous Java code: public static void main(String args[]) { // While loop set-up boolean flag = true; while (flag) { Scanner sc = new Scanner(System.in); // Ask user to enter employee number System.out.print("Enter employee number: "); int employee_number = sc.nextInt(); // Ask user to enter last name System.out.print("Enter employee last name: "); String last_name = sc.next(); // Ask user to enter number of hours worked System.out.print("Enter number of hours worked: "); int hours_worked =...

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
ADVERTISEMENT