/********************************************************************* * Author: Eric Heim * Date Created: 6/14/2011 * Course: CS0007 * Description: Shows the basic use of arrays *********************************************************************/ import java.text.DecimalFormat; import java.util.Scanner; public class Arrays1 { public static void main(String[] args) { final int NUM_EMPLOYEES = 3; final double EMPLOYEE_PAY_RATE = 9.50; double[] employeeHours = new double [NUM_EMPLOYEES]; Scanner keyboard = new Scanner(System.in); DecimalFormat formatter = new DecimalFormat("0.00"); System.out.println("Enter the hours worked for " + NUM_EMPLOYEES + " employees:"); System.out.print("Employee 1: "); employeeHours[0] = keyboard.nextDouble(); System.out.print("Employee 2: "); employeeHours[1] = keyboard.nextDouble(); System.out.print("Employee 3: "); employeeHours[2] = keyboard.nextDouble(); System.out.println("\nEmployee 1 made $" + formatter.format(employeeHours[0] * EMPLOYEE_PAY_RATE)); System.out.println("Employee 2 made $" + formatter.format(employeeHours[1] * EMPLOYEE_PAY_RATE)); System.out.println("Employee 3 made $" + formatter.format(employeeHours[2] * EMPLOYEE_PAY_RATE)); } }