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...
Write a program to calculate the amount of money in an account: The user will input...
Write a program to calculate the amount of money in an account: The user will input initial deposit and the number of years to leave that money in the account. The interest is constant at 0.5% for the entire length of time. The output will be the balance, with interest compounded annually. (simple interest formula: interest = principal * rate) What variables will you need to complete the program? What “controls” will you need for the program? What formula will...
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.
Using C++ write a program to calculate the amount a customer should pay in a self...
Using C++ write a program to calculate the amount a customer should pay in a self checkout counter for his purchases in a bagel shop. The products sold are everything bagels, garlic bagels, blueberry bagels, cream cheese, and coffee. Using "doWhile loops" write the program to display the menu of the Bagel shop. Make the user buy multiple items of different choices. Finally display the total amount for the purchases. Below is my current code to work with. Please add...
Write a program in python to calculate the amount each person must pay toward the bill...
Write a program in python to calculate the amount each person must pay toward the bill and toward the tip, for a group of friends who are eating out together. Since you are all friends, it is okay to split the costs evenly. Your program should take as input: The restaurant bill (without tax or tip) as a floating point number The sales tax rate as a floating point number (for example: an 8% tax rate would be 0.08) The...
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT