Question

In: Computer Science

Write a program to help a small company calculate the amount of money to pay its...

Write a program to help a small company calculate the amount of money to pay its employees. In this simplistic world, the company has exactly three employees. However, the number of hours per employee may vary. The company will apply the same tax rate to every employee

  • The program must be written in Java.
  • Prompt the user for the inputs and store the values in variables
  • Must include all the inputs and outputs listed here and perform the calculations correctly
    • Inputs (entered by the user of the program)
      • Name of the first employee
        • Hourly rate
        • Number of hours worked
      • Name of the second employee
        • Hourly rate
        • Number of hours worked
      • Name of the third employee
        • Hourly rate
        • Number of hours worked
      • Tax rate (between 0 and 1.0)
    • Processing and Output
      • Calculate and display the amount each employee will be paid before taxes
      • Calculate and display the amount each employee will be taxed
      • Calculate and display the amount each employee will be paid after taxes have been withheld
      • Calculate and display the total amount of taxes the company will withhold
  • Make the output look attractive
  • Comment your code.

You may separate the processing/calculation step from the output step or you may combine those steps. It is your choice

Solutions

Expert Solution

Java Program:

/* Java Program that calculates payroll of a company */

import java.util.Scanner;

public class Main
{
//Main method
   public static void main(String[] args) {
  
   //Scanner class object
   Scanner reader = new Scanner(System.in);
  
   //Array to hold names
   String[] names = new String[3];
  
   //Array to hold hourly rate
   double[] hourlyRate = new double[3];
  
   //Array to hold hours worked
   double[] hoursWorked = new double[3];
  
   //Reading data from User
   for(int i=0; i<3; i++)
   {
   System.out.print("\nEnter name of Employee #" + (i+1) + ": ");
   names[i] = reader.nextLine();
  
   System.out.print("Enter Hourly rate of Employee #" + (i+1) + ": ");
   hourlyRate[i] = reader.nextDouble();
  
   System.out.print("Enter Hours Worked by Employee #" + (i+1) + ": ");
   hoursWorked[i] = reader.nextDouble();
  
   reader.nextLine();
   }
  
   //Reading tax rate
   System.out.print("\n\nEnter tax rate (between 0 and 1.0): ");
   double taxRate = reader.nextDouble();
  
   double companyWithholdTax = 0.0;
  
   System.out.printf("\n %-15s %-15s %-15s %-15s \n", "Employee Name", "Pay Before Tax", "Tax Deducted", "Pay after Tax");
  
double tax, payBefore, payAfter;
  
   //Printing result
   for(int i=0; i<3; i++)
   {
//Before tax
payBefore = hoursWorked[i] * hourlyRate[i];
  
//Computing tax
tax = payBefore * taxRate;
  
//After taxRate
payAfter = payBefore - tax;
  
companyWithholdTax += tax;
  
   System.out.printf("\n %-18s %-15.2f %-15.2f %-15.2f ", names[i], payBefore, tax, payAfter);
   }
  
       System.out.printf("\n\nTotal amount of taxes company withhold: %.2f \n\n", companyWithholdTax);
   }
}

____________________________________________________________________________________________________

Sample Run:


Related Solutions

You are asked to write a program to help a small company calculate the amount of...
You are asked to write a program to help a small company calculate the amount of money to pay their employees. In this simplistic world, the company has exactly three employees. However, the number of hours per employee may vary. The company will apply the same tax rate to every employee. Problem Description Inputs (entered by user of the program) • Name of first employee • Hourly rate • Number of hours worked • Name of second employee • Hourly...
Using C++ Write a program to calculate the amount a customer should pay in a checkout...
Using C++ Write a program to calculate the amount a customer should pay in a checkout counter for the purchases in a bagel shop. The products sold are bagels, cream cheese, and coffee. Use the pseudo code discussed in the class to write the program. Make reasonable assumptions about the prices of bagel, cream cheese, and coffee. Declare prices of bagel, cream cheese, and coffee as constants.
Overview For this assignment, write a program that will calculate the amount that a customer spends...
Overview For this assignment, write a program that will calculate the amount that a customer spends on tickets at a movie theater. This program will be continued in program 3 so it is important that this program is completed. Basic Program Logic The basic logic for this program is similar to program 1: the user is asked to enter values, a calculation is performed, and the result of the calculation is displayed. For this program, prompt the user for the...
Use the switch structure to write a MATLAB program to compute the amount of money that accumulates
Use the switch structure to write a MATLAB program to compute the amount of money that accumulates in a savings account in one year. The program should accept the following input: the initial amount of money deposited in the account; the frequency of interest compounding (monthly, quarterly, semiannually, or annually); and the interest rate. Run your program for a $1000 initial deposit for each case; use a 5 percent interest rate. Compare the amounts of money that accumulate for each...
In the space provided below write a C program that computes the total amount of money...
In the space provided below write a C program that computes the total amount of money you have stored in your piggy bank. Your program does this by asking you for number of pennies, nickels, dimes, and quarters in the piggy bank and then displays how much money in total is in the piggy bank.
Write a program that can calculate the amount of federal tax aperson owes for the...
Write a program that can calculate the amount of federal tax a person owes for the upcoming year.After calculating the amount of tax owed, you should report to the user their filing status (single/joint), which tax rate they fell under, as well as the tax owed. Example: “As a single filer you fell under 12% tax bracket and you owe $3500.”Disclaimer: This example is simplified and is not intended to be an accurate representation of how to calculate your taxes.Your...
A company wants a program that will calculate the basic pay information for all of their...
A company wants a program that will calculate the basic pay information for all of their employees. The following requirements are necessary to make the program work as it needs to: This program must allow the user to input whether he or she is hourly or salaried. If salaried, the employee should be prompted to enter a weekly salary. If hourly, the employee should be prompted to enter an hourly wage and the number of hours worked, so that the...
Python programming c++ Write a program that computes the amount of money the cheerleaders raised during...
Python programming c++ Write a program that computes the amount of money the cheerleaders raised during their candy bar fundraiser using the following data: 12 bars per case. The candy was sold for $1.00 per bar. Each case cost $8.00. They are required to give the student government association 10% of their earnings. The program should ask the user how many bars were sold. The program should calculate and display the SGA proceed's, the Cheer team's proceeds, and the appropriate...
Calculate the amount of money that will be in each of the following accounts at the...
Calculate the amount of money that will be in each of the following accounts at the end of the given deposit​ period: Account Holder Amount Deposited Annual Interest Rate Compounding Periods Per Year​ (M) Compounding Periods​ (Years) Theodore Logan III ​$ 900 16% ​ 2 6 Vernell Coles 96,000 8 4 2 Tina Elliot 9,000 12 12 6 Wayne Robinson 120,000 10 6 5 Eunice Chung 29,000 18 3 6 Kelly Cravens 13,000 10 1 4
Calculate the amount of money that will be in each of the following accounts at the...
Calculate the amount of money that will be in each of the following accounts at the end of the given deposit​ period: Account Holder Amount Deposited Annual Interest Rate Compounding Periods Per Year (M) Compounding Periods (Years) Theodore Logan III $1,000 12% 4 10 Vernell Coles $96,000 8% 12 3 Tina Elliot $8,000 12% 6 6 Wayne Robinson $122,000 10% 1 3 Eunice Chung $31,000 12% 3 6 Kelly Cravens $16,000 10% 2 4  The amount of money in Theodore...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT