×
Reviews 4.9/5 Order Now

Program To Calculate Total Hours of Employees in Java Language Assignment Solution

July 09, 2024
Dr. Erin Kim
Dr. Erin
🇺🇸 United States
Java
Dr. Erin Kim, an esteemed Ph.D. graduate from the University of Texas, stands out with over 9 years of comprehensive experience in providing Java Assignment Help. With a remarkable portfolio of 1000+ completed Java assignments, Dr. Kim's expertise and dedication guarantee superior results, addressing even the most challenging tasks with ease.
Key Topics
  • Instructions
    • Objective
  • Requirements and Specifications
Tip of the day
Break problems into small functions and test each part early. Use virtual environments and clear variable names, and rely on official documentation or docstrings to avoid guesswork. Clean, readable Python often scores better than overly complex solutions.
News
Starting in Fall 2026, the University of South Florida’s Bellini College of Artificial Intelligence, Cybersecurity and Computing will introduce three new interdisciplinary computing majors that blend computer science and AI with fields like business and criminology — expanding programming-focused study options.

Instructions

Objective

Write a java assignment program to calculate total hours of employees.

Requirements and Specifications

The array below shows the number of hours an employee has worked each week for 26 weeks.

Write code to compute and print:

The number of weeks the employee worked overtime (more than 40 hours).

The total number of overtime hours accumulated.

If the regular pay = $25 per hour, find the total gross pay after 26 weeks (time and half for more than 40 hours of work, no penalty for sick/vacation time).

int []hours = {40, 48, 40, 40, 32, 40, 45, 40, 40, 42, 28, 40, 45, 40, 40, 40, 50, 45, 48, 40, 32, 28, 40, 40, 45, 40};

Using the following tax rates, compute the total taxes paid after 26 weeks.

Gross Pay

Tax rate

0 to $1100

5%

$1101 and above

7%

Source Code

public class App { public static void main(String[] args) throws Exception { // Array with hours int[] hours = {40, 48, 40, 40, 32, 40, 45, 40, 40, 42, 28, 40, 45, 40, 40, 40, 50, 45, 48, 40, 32, 28, 40}; // Count number of week that the employee worked overtime int weeks_overtime = 0; int overtime_hours = 0; double regular_pay = 25; double overtime_pay = 1.5*regular_pay; double gross_pay = 0.0; double taxes = 0.0; double net_pay; for(int i = 0; i < hours.length; i++) { if(hours[i] > 40) { weeks_overtime++; overtime_hours += hours[i]; gross_pay += regular_pay*40 + overtime_pay*(hours[i]-40); } else gross_pay += regular_pay*hours[i]; } // Calculate taxes if(gross_pay > 1100) taxes = 0.07*gross_pay; else taxes = 0.05*gross_pay; net_pay = gross_pay - taxes; // Print System.out.printf("%10s:%11.4f\n", "Gross Pay", gross_pay); System.out.printf("%10s:%11.4f\n", "Taxes", taxes); System.out.printf("%10s:%11.4f\n", "Net Pay", net_pay); } }

Similar Samples

Discover ProgrammingHomeworkHelp.com’s comprehensive programming assignment samples. From Java and Python to C++ and SQL, each example illustrates our proficiency in solving diverse programming challenges. Explore our samples to see how we can assist you in mastering coding concepts and achieving academic success.