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
Java please At this point in your life most of you have or have had a...
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 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? 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 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 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, 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 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 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 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[]) { // 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 =...