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

Create an application that would: -Ask your user to input the employee informati

ID: 3823659 • Letter: C

Question

Create an application that would:

-Ask your user to input the employee information

-Calculate the taxes

Output all the info along with the table that includes:

-Paycheck number (1, c2, 3, etc. up to 24)

-Salary prior to withholding for each paycheck

-State and federal taxes for each paycheck

-Salary after withholdings

-Last line has to have all the totals for the above

First class:

Represents an Employee Tax information

Include the following characteristics: employee ID, full name, tax filing status (such as married filing separately, etc. ), monthly salary (prior to withholdings), federal and state taxes (percentages), number of pay periods per year, and monthly amount withheld for each tax

Write at least two constructors

Include properties for each of the data items

Include all the necessary calculations, including the determination of the tax percentage for each federal and state tax

Override the ToString() method to return all data members

Second class:

Tests Employee Tax class

Displays instructions to your user (a short description of your application)

Asks your user to input the information and writes it in the corresponding fields of each object

Asks your user whether another employee information needs to be entered (do…while)

Test your class with at least three employees with different salaries within different tax brackets

Display the data from the first object using a class method (you will need some method DisplayObject(…)), and the other two objects via the reference to ToString() instance method.

Make sure to use modular solution (with multiple methods)

Include at least one iteration and one condition statements

Explanation / Answer

import java.util.*;
//Class EmployeeTax definition
class EmployeeTax
{
   //Instance variables
String EmployeeID;
String FullName;
char TaxFilingStatus;
double MonthlySalary, FederalTax, StateTax;
int NumberOfPayPeriodsPerYear;
double MonthlyAmountWithheld;
//Default Constructor
EmployeeTax()
{
EmployeeID = "";
FullName = "";
TaxFilingStatus = 'n';
MonthlySalary = 0.0;
FederalTax = 0;
StateTax = 0;
NumberOfPayPeriodsPerYear = 0;
MonthlyAmountWithheld = 0;
}//End of constructor
  
//Parameterized constructor
EmployeeTax(String id, String fn, char ch, double ms, double ft, double st, int np)
{
EmployeeID = id;
FullName = fn;
TaxFilingStatus = ch;
MonthlySalary = ms;
FederalTax = ft;
StateTax = st;
NumberOfPayPeriodsPerYear = np;
}//End of constructor
  
//To calculate tax
void calcualte()
{
   //If tax filling status is Y or y then calculate tax
if(TaxFilingStatus == 'Y' || TaxFilingStatus == 'y')
{
MonthlyAmountWithheld = (MonthlySalary * ((FederalTax / 100)/12)) + (MonthlySalary * ((StateTax / 100)/12));
}//End of if
//Otherwise no tax
else
   MonthlyAmountWithheld = 0;
}//End of method
//Overrides toString() method
public String toString()
{
   String msg = "";
   //Concatenates the results
   msg += " Employee ID = " + EmployeeID + " Full Name = " + FullName + " Tax Filing Status = " + TaxFilingStatus
+ " Monthly Salary = " + MonthlySalary + " Federal Tax " + FederalTax + " State Tax " + StateTax
+ " Number Of Pay Periods Per Year " + NumberOfPayPeriodsPerYear + " Monthly Amount Withheld " + MonthlyAmountWithheld;
   //Return result
   return msg;
}//End of method
//Method to display information
void show()
{
   System.out.println(" Employee ID = " + EmployeeID + " Full Name = " + FullName + " Tax Filing Status = " + TaxFilingStatus
+ " Monthly Salary = " + MonthlySalary + " Federal Tax " + FederalTax + " State Tax " + StateTax
+ " Number Of Pay Periods Per Year " + NumberOfPayPeriodsPerYear + " Monthly Amount Withheld " + MonthlyAmountWithheld);
}//End of method
}//End of class

//Driver class
public class TestsEmployeeTax
{
   //Main method
   public static void main(String ss[])
   {
       //Creates an array of objects
       EmployeeTax et[] = new EmployeeTax[10];
       //Creates a scanner class object to accept data
       Scanner sc = new Scanner(System.in);
       char ch;
       int count = 0;
       //Loops till user choice
       do
       {
           //Initialize an object
           et[count] = new EmployeeTax();
           //Accepts information
           System.out.println(" Enter Employee Id: ");
           et[count].EmployeeID = sc.next();
           System.out.println(" Enter Employee Name: ");
           et[count].FullName = sc.next();
           System.out.println(" Enter Tax filling status (y for YES n for No): ");
           et[count].TaxFilingStatus = sc.next().charAt(0);
           System.out.println(" Enter Monthly salary: ");
           et[count].MonthlySalary = sc.nextDouble();
           //If tax filling status is y or Y then accept federal tax and state tax
           if(et[count].TaxFilingStatus == 'Y' || et[count].TaxFilingStatus == 'y')
           {
               System.out.println(" Enter Federal Tax: ");
               et[count].FederalTax = sc.nextDouble();
               System.out.println(" Enter State Tax: ");
               et[count].StateTax = sc.nextDouble();              
           }//End of if
           System.out.println(" Enter Number Of Pay Periods Per Year: ");
           et[count].NumberOfPayPeriodsPerYear = sc.nextInt();
           //Calculate tax
           et[count].calcualte();
           //Accepts user choice
           System.out.println(" Would you like to enter another employee information (Y for yes N for no)");
           ch = sc.next().charAt(0);
           //Increase the counter by one
           count++;
           //If the choice is N or n then break
           if(ch == 'N' || ch == 'n')
               break;
       }while(true);
       //Display the first employee information using function
       et[0].show();
       //Display other employee information using toString()
       for(int x = 1; x < count; x++)
           System.out.println(et[x]);
   }//End of main method
}//End of class

Output:


Enter Employee Id:
111

Enter Employee Name:
Pyari

Enter Tax filling status (y for YES n for No):
y

Enter Monthly salary:
5000

Enter Federal Tax:
10

Enter State Tax:
12

Enter Number Of Pay Periods Per Year:
3

Would you like to enter another employee information (Y for yes N for no)
Y

Enter Employee Id:
222

Enter Employee Name:
Mohan

Enter Tax filling status (y for YES n for No):
Y

Enter Monthly salary:
6000

Enter Federal Tax:
12

Enter State Tax:
13

Enter Number Of Pay Periods Per Year:
3

Would you like to enter another employee information (Y for yes N for no)
y

Enter Employee Id:
333

Enter Employee Name:
Sahu

Enter Tax filling status (y for YES n for No):
n

Enter Monthly salary:
4000

Enter Number Of Pay Periods Per Year:
3

Would you like to enter another employee information (Y for yes N for no)
N

Employee ID = 111
Full Name = Pyari
Tax Filing Status = y
Monthly Salary = 5000.0
Federal Tax 10.0
State Tax 12.0
Number Of Pay Periods Per Year 3
Monthly Amount Withheld 91.66666666666666

Employee ID = 222
Full Name = Mohan
Tax Filing Status = Y
Monthly Salary = 6000.0
Federal Tax 12.0
State Tax 13.0
Number Of Pay Periods Per Year 3
Monthly Amount Withheld 125.0

Employee ID = 333
Full Name = Sahu
Tax Filing Status = n
Monthly Salary = 4000.0
Federal Tax 0.0
State Tax 0.0
Number Of Pay Periods Per Year 3
Monthly Amount Withheld 0.0

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