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

In the C programing Language with documentation: Write a program that interactiv

ID: 653850 • Letter: I

Question

In the C programing Language with documentation:

Write a program that interactively accepts the employee number, last name, pay rate and hours worked. Declare a single structure type suitable for an employee record consisting of an integer identification number, a last name (consisting of a max of 20 characters), a floating-point pay rate, and a floating-point number of hours worked. Once the data have been entered, the program should create a payroll report listing each employees name, number, and gross pay. Include the total gross pay of all employees at the end of the report. Sample output:

Explanation / Answer

import java.text.DecimalFormat;
import java.util.Scanner;
public class USER {
public static void main(String[] args)
{
double[] array= new double[5];
Scanner scanner = new Scanner(System.in);
System.out.println("Enter the hours for five employees: ");
System.out.println("Enter the hours worked for employee # 1: ");
array[0]= scanner.nextDouble();
System.out.println("Enter the hours worked for employee # 2: ");
array[1]= scanner.nextDouble();
System.out.println("Enter the hours worked for employee # 3: ");
array[2]= scanner.nextDouble();
System.out.println("Enter the hours worked for employee # 4: ");
array[3]= scanner.nextDouble();
System.out.println("Enter the hours worked for employee # 5: ");
array[4]= scanner.nextDouble();
  
System.out.println("Enter the hourly rate (it is the same for all employees): ");
double hourly_wage= scanner.nextDouble();
  
System.out.println("The gross pay for each emloyee is");
  
for(int i=0 ; i<5; i++)
{
System.out.println("Employee # " +(i+1) + " :" + hourly_wage*array[i]);

}
DecimalFormat df = new DecimalFormat();
df.setMaximumFractionDigits(2);
System.out.println();
System.out.println();
System.out.println("The gross pay for each emloyee in 2 decimals is");

for(int i=0 ; i<5; i++)
{
System.out.println("Employee # " +(i+1) + " :" + df.format(hourly_wage*array[i]));

}
}
}