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

Write the 2 following array programs. Want it in JAVA The EIRST array programmin

ID: 3825522 • Letter: W

Question

Write the 2 following array programs. Want it in JAVA The EIRST array programming assignment is from pp. 405-435 This is a simple array program which does not use an "external class & demo program" If you wish, you may break it down into methods, but that is not required. a. Set up 4 arrays which each hold 6 employee's data: int[] empid int[] hours double[] rate double [] wages b. Set up a loop or loops to load the hours and rate arrays c TAKING OVERTIME [hours > 40], INTO CONSIDERATION, thru the use of the IF statement Set up a loop to calculate values for the wages array. d. Set up a loop to print the empid and wages for each employee

Explanation / Answer

PROGRAM CODE:

package array;

import java.util.Scanner;

public class ArrayProgram {

   public static void main(String[] args) {

       Scanner keyboard = new Scanner(System.in);

       double overTimeRate = 20.00;

       int empid[] = new int[6];

       int hours[] = new int[6];

       double rate[] = new double[6];

       double wages[] = new double[6];

       for(int i=0; i<6; i++)

       {

           System.out.print("Enter employee id: ");

           empid[i] = Integer.valueOf(keyboard.next());

           System.out.print("Enter hours worked: ");

           hours[i] = Integer.valueOf(keyboard.next());

           System.out.print("Enter rate/hr: ");

           rate[i] = Integer.valueOf(keyboard.next());

           wages[i] = rate[i]*hours[i];

           if(hours[i]>40)

               wages[i] += (hours[i]-40) * overTimeRate;

       }

       System.out.println(" ");

       for(int i=0; i<6; i++)

       {

           System.out.println("Employee ID: " + empid[i] + " wages: $" + wages[i]);

       }

   }

}

OUTPUT:

Enter employee id: 11201

Enter hours worked: 36

Enter rate/hr: 30

Enter employee id: 11202

Enter hours worked: 49

Enter rate/hr: 25

Enter employee id: 11203

Enter hours worked: 45

Enter rate/hr: 31

Enter employee id: 11204

Enter hours worked: 35

Enter rate/hr: 25

Enter employee id: 11205

Enter hours worked: 30

Enter rate/hr: 30

Enter employee id: 11206

Enter hours worked: 50

Enter rate/hr: 25

Employee ID: 11201 wages: $1080.0

Employee ID: 11202 wages: $1405.0

Employee ID: 11203 wages: $1495.0

Employee ID: 11204 wages: $875.0

Employee ID: 11205 wages: $900.0

Employee ID: 11206 wages: $1450.0

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote