1. Write an application that stores nine integers in an array. Display the integers from first to last, and then display the integers from last to first. Save the file as NineInts.java.

    public class NineInts { public static void main (String args[]) { int[] numbers = {10, 15, 19, 23, 26, 29, 31, 34, 38}; int i; for (i = 0; i < numbers.length; i++) System.out.print(numbers[i] + " "); System.out.println(); for (i = numbers.length - 1; i >= 0; i--) System.out.print("" + numbers[i] + " "); System.out.println(); } }
  2. Allow a user to enter any number of double values up to 15. The user should enter 99999 to quit entering numbers. Display an error message if the user quits without entering any numbers; otherwise, display each entered value and its distance from the average. Save the file as DistanceFromAverage.java.

    import java.util.*; public class DistanceFromAverage { public static void main (String[] args) { Scanner input = new Scanner(System.in); double[] numbers = new double[15]; double entry; double total = 0; double average = 0; final int QUIT = 99999; int x = 0, y; System.out.print("Enter a numeric value or " + QUIT + " to quit >> "); entry = input.nextDouble(); while(entry != QUIT && x < numbers.length) { numbers[x] = entry; total += numbers[x]; ++x; if(x < numbers.length) { System.out.print("Enter next numeric value or " + QUIT + " to quit >> "); entry = input.nextDouble(); } } if(x == 0) System.out.println("Average cannot be computed because no numbers were entered"); else { average = total / x; System.out.println("You entered " + x + " numbers and their average is " + average); for(y = 0; y < x; ++y) System.out.println(numbers[y] + " is " + (numbers[y] - average) + " away from the average"); } } }
    1. Write an application for Cody’s Car Care Shop that shows a user a list of available services: oil change, tire rotation, battery check, or brake inspection. Allow the user to enter a string that corresponds to one of the options, and display the option and its price as $25, $22, $15, or $5, accordingly. Display an error message if the user enters an invalid item. Save the file as CarCareChoice.java.

      import javax.swing.*; public class CarCareChoice { public static void main (String[] args) { boolean isMatch = false; String[] items = { "oil change", "tire rotation", "battery check", "brake inspection"}; int[] prices = {25, 22, 15, 5}; int x; int matchIndex = 0; String menu = "Enter selection:"; for(x = 0; x < items.length; ++x) menu += "\n " + items[x]; String selection = JOptionPane.showInputDialog(null, menu); for (x = 0; x < items.length; x++) if(selection.equals(items[x])) { isMatch = true; matchIndex = x; } if(isMatch) JOptionPane.showMessageDialog(null, selection + " price is $" + prices[matchIndex]); else JOptionPane.showMessageDialog(null, "Invalid Entry"); } }
    2. It might not be reasonable to expect users to type long entries such as “oil change” accurately. Modify the CarCareChoice class so that as long as the user enters the first three characters of a service, the choice is considered valid. Save the file as CarCareChoice2.java

      import javax.swing.*; public class CarCareChoice2 { public static void main (String[] args) { boolean isMatch = false; String[] items = { "oil change", "tire rotation", "battery check", "brake inspection"}; int[] prices = {25, 22, 15, 5}; int x; int matchIndex = 0; String menu = "Enter selection:"; for(x = 0; x < items.length; ++x) menu += "\n " + items[x]; String selection = JOptionPane.showInputDialog(null, menu); for (x = 0; x < items.length; x++) if(selection.substring(0, 3).equals(items[x].substring(0, 3))) { isMatch = true; matchIndex = x; } if(isMatch) JOptionPane.showMessageDialog(null, items[matchIndex] + " price is $" + prices[matchIndex]); else JOptionPane.showMessageDialog(null, "Invalid Entry"); } }
  3. Create an application containing an array that stores eight integers. The application should call five methods that in turn (1) display all the integers, (2) display all the integers in reverse order, (3) display the sum of the integers, (4) display all values less than a limiting argument, and (5) display all values that are higher than the calculated average value. Save the file as ArrayMethodDemo.java.

    public class ArrayMethodDemo { public static void main (String args[]) { int[] numbers = {12, 15, 34, 67, 4, 9, 10, 7, 13, 50}; int limit = 12; display(numbers); displayReverse(numbers); displaySum(numbers); displayLessThan(numbers, limit); displayHigherThanAverage(numbers); } public static void display(int[] numbers) { System.out.print("The numbers are "); for(int i = 0; i < numbers.length; ++ i) System.out.print(numbers[i] + " "); } public static void displayReverse(int[] numbers) { System.out.print("\nThe numbers in reverse order are "); for(int i = numbers.length - 1; i >= 0; -- i) System.out.print(numbers[i] + " "); } public static void displaySum(int[] numbers) { int total = 0; for(int i = 0; i < numbers.length; i++) { total += numbers[i]; } System.out.println("\nThe sum of all numbers is " + total); } public static void displayLessThan(int[] numbers, int limit) { for(int i = 0; i < numbers.length; i++) if(numbers[i] < limit) System.out.print(numbers[i] + " "); System.out.println("are less than the limit " + limit); } public static void displayHigherThanAverage(int[] numbers) { int sum = 0; double average; for(int i = 0; i < numbers.length; ++i) sum += numbers[i]; average = sum * 1.0 / numbers.length; System.out.println("The average is " + average); for(int i = 0; i < numbers.length; i++) if(numbers[i] > average) System.out.print(numbers[i] + " "); System.out.println("are greater than the average"); } }
    1. Write an application that accepts up to 20 Strings, or fewer if the user enters a terminating value. Store each String in one of two lists—one list for short Strings that are 10 characters or fewer and another list for long Strings that are 11 characters or more. After data entry is complete, prompt the user to enter which type of String to display, and then output the correct list. For this exercise, you can assume that if the user does not request the list of short strings, the user wants the list of long strings. If a requested list has no Strings, output an appropriate message. Prompt the user continuously until a sentinel value is entered. Save the file as CategorizeStrings.java.

      import java.util.*; public class CategorizeStrings { public static void main (String[] args) { final int MAX = 20; final int CUTOFF = 10; final String QUIT = "ZZZ"; String entry; int shortSub = 0; int longSub = 0; Scanner input = new Scanner(System.in); String[] longStrings = new String[MAX]; String[] shortStrings = new String[MAX]; System.out.print("Enter a string or " + QUIT + " to quit >> "); entry = input.nextLine(); while(!entry.equals(QUIT) && (shortSub + longSub < MAX)) { if(entry.length() <= CUTOFF) { shortStrings[shortSub] = entry; ++shortSub; } else { longStrings[longSub] = entry; ++longSub; } if(shortSub + longSub < MAX) { System.out.print("Enter a string or " + QUIT + " to quit >> "); entry = input.nextLine(); } } System.out.println("\nDo you want to see the list of short strings or the list of long strings?"); System.out.print(" Please enter S or L or " + QUIT + " to quit >> "); entry = input.nextLine(); while(!entry.equals(QUIT)) { if(entry.substring(0, 1).toLowerCase().equals("s")) display(shortStrings, shortSub); else display(longStrings, longSub); System.out.println("\nDo you want to see the list of short strings or the list of long strings?"); System.out.print(" Please enter S or L or " + QUIT + " to quit >> "); entry = input.nextLine(); } } public static void display(String[] array, int max) { System.out.println(); if(max == 0) System.out.println("The list is empty"); else for(int x = 0; x < max; ++x) System.out.println(array[x]); } }
    2. Modify the CategorizeStrings application to divide the entered Strings into those that contain no spaces, one space, or more. After data entry is complete, continuously prompt the user to enter the type of String to display. If the user does not enter one of the three valid choices, display all of the Strings. Save the file as CategorizeStrings2.java.

      import java.util.*; public class CategorizeStrings2 { public static void main (String[] args) { final int MAX = 20; final int CUTOFF = 10; final String QUIT = "ZZZ"; String entry; int spaces; int oneWordSub = 0; int twoWordsSub = 0; int threeWordsSub = 0; Scanner input = new Scanner(System.in); String[] oneWord = new String[MAX]; String[] twoWords = new String[MAX]; String[] threeWords = new String[MAX]; System.out.print("Enter a string or " + QUIT + " to quit >> "); entry = input.nextLine(); while(!entry.equals(QUIT) && (oneWordSub + twoWordsSub + threeWordsSub < MAX)) { spaces = 0; for(int x = 0; x < entry.length(); ++x) { if(entry.charAt(x) == ' ') ++spaces; } if(spaces == 0) { oneWord[oneWordSub] = entry; ++oneWordSub; } else if(spaces == 1) { twoWords[twoWordsSub] = entry; ++twoWordsSub; } else { threeWords[threeWordsSub] = entry; ++threeWordsSub; } if(oneWordSub + twoWordsSub + threeWordsSub < MAX) { System.out.print("Enter a string or " + QUIT + " to quit >> "); entry = input.nextLine(); } } System.out.println("\nDo you want to see the list of" + "\n one-word strings," + " two-word strings, or longer strings?"); System.out.print(" Please enter O, T, or L, or " + QUIT + " to quit >> "); entry = input.nextLine(); while(!entry.equals(QUIT)) { String letter = entry.substring(0,1).toLowerCase(); if(letter.equals("o")) display(oneWord, oneWordSub, "one-word"); else if(letter.equals("t")) display(twoWords, twoWordsSub, "two-word"); else if(letter.equals("l")) display(threeWords, threeWordsSub, "longer"); else { display(oneWord, oneWordSub, "one-word"); display(twoWords, twoWordsSub, "two-word"); display(threeWords, threeWordsSub, "longer"); } System.out.println("\nDo you want to see the list of" + "\n one-word strings," + " two-word strings, or longer strings?"); System.out.print(" Please enter O, T, or L, or " + QUIT + " to quit >> "); entry = input.nextLine(); } } public static void display(String[] array, int max, String msg) { System.out.println("\nList of " + msg + " strings:"); if(max == 0) System.out.println("The list is empty"); else for(int x = 0; x < max; ++x) System.out.println(array[x]); } }
    1. Create a class named Salesperson. Data fields for Salesperson include an integer ID number and a double annual sales amount. Methods include a constructor that requires values for both data fields, as well as get and set methods for each of the data fields. Write an application named DemoSalesperson that declares an array of 10 Salesperson objects. Set each ID number to 9999 and each sales value to zero. Display the 10 Salesperson objects. Save the files as Salesperson.java and DemoSalesperson.java.

      public class DemoSalesperson { public static void main (String args[]) { Salesperson[] salesPeople = new Salesperson[10]; int i; for (i = 0; i < salesPeople.length; i++) salesPeople[i] = new Salesperson(9999, 0); for (i = 0; i < salesPeople.length; i++) System.out.println("Salesperson " + i + " has ID #" + salesPeople[i].getId() + " and annual sales of $" + salesPeople[i].getSales()); } }
    2. Modify the DemoSalesperson application so each Salesperson has a successive ID number from 111 through 120 and a sales value that ranges from $25,000 to $70,000, increasing by $5,000 for each successive Salesperson. Save the file as DemoSalesperson2.java.

      public class DemoSalesperson2 { public static void main (String args[]) { Salesperson[] salesPeople = new Salesperson[10]; int i; int assignId = 111; int assignSales = 25000; final int SALES_INCREASE = 5000; for (i = 0; i < salesPeople.length; i++) { salesPeople[i] = new Salesperson(assignId, assignSales); ++assignId; assignSales += SALES_INCREASE; } for (i = 0; i < salesPeople.length; i++) System.out.println("Salesperson " + i + " has ID #" + salesPeople[i].getId() + " and annual sales of $" + salesPeople[i].getSales()); } }
    1. Create a CollegeCourse class. The class contains fields for the course ID (for example, CIS 210), credit hours (for example, 3), and a letter grade (for example, A). Include get and set methods for each field. Create a Student class containing an ID number and an array of five CollegeCourse objects. Create a get and set method for the Student ID number. Also create a get method that returns one of the Student’s CollegeCourses; the method takes an integer argument and returns the CollegeCourse in that position (0 through 4). Next, create a set method that sets the value of one of the Student’s CollegeCourse objects; the method takes two arguments—a CollegeCourse and an integer representing the CollegeCourse’s position (0 through 4). Save the files as CollegeCourse.java and Student.java.

      public class CollegeCourse { private String courseID; private int credits; private char grade; public String getID() { return courseID; } public int getCredits() { return credits; } public char getGrade() { return grade; } public void setID(String idNum) { courseID = idNum; } public void setCredits(int cr) { credits = cr; } public void setGrade(char gr) { grade = gr; } }
      public class Student { private int stuID; private CollegeCourse[] course = new CollegeCourse[5]; public int getID() { return stuID; } public CollegeCourse getCourse(int x) { return course[x]; } public void setID(int idNum) { stuID = idNum; } public void setCourse(CollegeCourse c, int x) { course[x] = c; } }
    2. Write an application that prompts a professor to enter grades for five different courses each for 10 students. Prompt the professor to enter data for one student at a time, including student ID and course data for five courses. Use prompts containing the number of the student whose data is being entered and the course number—for example, Enter ID for student #1, and Enter course ID #5. Verify that the professor enters only A, B, C, D, or F for the grade value for each course. Save the file as InputGrades.java.

      import javax.swing.*; public class InputGrades { public static void main(String[] args) { Student[] students = new Student[10]; int x, y, z; String courseEntry, entry = "", message; int idEntry, credits; char gradeEntry = ' '; boolean isGoodGrade = false; char[] grades = {'A', 'B', 'C', 'D', 'F'}; final int NUM_COURSES = 5; for(x = 0; x < students.length; ++x) { Student stu = new Student(); entry = JOptionPane.showInputDialog(null, "For student #" + (x + 1) + ", enter the student ID"); idEntry = Integer.parseInt(entry); stu.setID(idEntry); for(y = 0; y < NUM_COURSES; ++y) { courseEntry = JOptionPane.showInputDialog(null, "For student #" + (x + 1) + ", enter course #" + (y + 1)); entry = JOptionPane.showInputDialog(null, "For student #" + (x + 1) + ", enter credits for course #" + (y + 1)); credits = Integer.parseInt(entry); isGoodGrade = false; while(!isGoodGrade) { entry = JOptionPane.showInputDialog(null, "For student #" + (x + 1) + ", enter grade for course #" + (y + 1)); gradeEntry = entry.charAt(0); for(z = 0; z < grades.length; ++z) { if(gradeEntry == grades[z]) isGoodGrade = true; } } CollegeCourse temp = new CollegeCourse(); temp.setID(courseEntry); temp.setCredits(credits); temp.setGrade(gradeEntry); stu.setCourse(temp, y); } students[x] = stu; } for(x = 0; x < students.length; ++x) { message = "Student #" + (x + 1) + " ID #" + students[x].getID(); for(y = 0; y < grades.length; ++y) { CollegeCourse temp = new CollegeCourse(); temp = students[x].getCourse(y); message = message + "\n" + temp.getID() + " " + temp.getCredits() + " -- credits. Grade is " + temp.getGrade(); } JOptionPane.showMessageDialog(null, message); } } }
  4. Write an application that allows a user to enter the names and birthdates of up to 10 friends. Continue to prompt the user for names and birthdates until the user enters the sentinel value ZZZ for a name or has entered 10 names, whichever comes first. When the user is finished entering names, produce a count of how many names were entered, and then display the names. In a loop, continuously ask the user to type one of the names and display the corresponding birthdate or an error message if the name has not been previously entered. The loop continues until the user enters ZZZ for a name. Save the application as BirthdayReminder.java.

    import javax.swing.*; public class BirthdayReminder { public static void main(String[] args) { final int MAX = 10; final String QUIT = "ZZZ"; String[] names = new String[MAX]; String[] birthdates = new String[MAX]; String entry; String msg; String list = ""; int count = 0, x; boolean isFound = false; entry = JOptionPane.showInputDialog(null, "Enter a name"); names[count] = entry; while(count < names.length && (!entry.equals(QUIT)) ) { entry = JOptionPane.showInputDialog(null, "Enter birthdate with slashes between the month, day, and year"); birthdates[count] = entry; ++count; if(count < names.length) { entry = JOptionPane.showInputDialog(null, "Enter a name or " + QUIT + " to quit"); names[count] = entry; } } JOptionPane.showMessageDialog(null, "Count of names entered: " + count); for(x = 0; x < count; ++x) list += names[x] + "\n"; JOptionPane.showMessageDialog(null, list); entry = JOptionPane.showInputDialog(null, "Enter a name to search for"); while(!entry.equals(QUIT)) { isFound = false; for(x = 0; x < count; ++x) if (entry.equals(names[x])) { isFound = true; JOptionPane.showMessageDialog(null, names[x] + "'s birthdate is " + birthdates[x]); } if(!isFound) msg = "Sorry, no entry for " + entry + "\n"; else msg = ""; entry = JOptionPane.showInputDialog(null, msg + "Enter a name to search for or " + QUIT + " to quit"); } } }
  5. A personal phone directory contains room for first names and phone numbers for 30 people. Assign names and phone numbers for the first 10 people. Prompt the user for a name, and if the name is found in the list, display the corresponding phone number. If the name is not found in the list, prompt the user for a phone number, and add the new name and phone number to the list. Continue to prompt the user for names until the user enters quit. After the arrays are full (containing 30 names), do not allow the user to add new entries. Save the file as PhoneNumbers.java.

    import javax.swing.*; class PhoneNumbers { public static void main(String[] args) { String[] names = new String[30]; names[0] = "Gina"; names[1] = "Marcia"; names[2] = "Rita"; names[3] = "Jennifer"; names[4] = "Fred"; names[5] = "Neil"; names[6] = "Judy"; names[7] = "Arlene"; names[8] = "LaWanda"; names[9] = "Deepak"; String numbers[] = new String[30]; numbers[0] = "(847) 341-0912"; numbers[1] = "(847) 341-2392"; numbers[2] = "(847) 354-0654"; numbers[3] = "(414) 234-0912"; numbers[4] = "(414) 435-6567"; numbers[5] = "(608) 123-0904"; numbers[6] = "(608) 435-0434"; numbers[7] = "(608) 123-0312"; numbers[8] = "(920) 787-9813"; numbers[9] = "(930) 412-0991"; String entryName, entryPhone; int x; boolean isFound = false; int highest = 10; entryName = JOptionPane.showInputDialog(null, "Enter name to look up. Type 'quit' to quit."); while (highest < 30 && !entryName.equals("quit")) { for(x = 0; x < highest; ++ x) if(entryName.equals(names[x])) { isFound = true; JOptionPane.showMessageDialog(null, names[x] + "'s phone number is " + numbers[x]); x = highest; } if(!isFound) { entryPhone= JOptionPane.showInputDialog(null, "Enter phone number for " + entryName); names[highest] = entryName; numbers[highest] = entryPhone; ++highest; } entryName = JOptionPane.showInputDialog(null, "Enter name to look up. Type 'quit' to quit."); isFound = false; } } }
  6. In the exercises in Chapter 4, you created a CertOfDeposit class. Now, create an application to accept data for an array of five CertOfDeposit objects, and then display the data. Save the application as CertOfDepositArray.java.

    import java.time.*; public class CertOfDeposit { private String certNum; private String lastName; private double balance; private LocalDate issueDate; private LocalDate maturityDate; public CertOfDeposit(String num, String name, double bal, LocalDate issue) { certNum = num; lastName = name; balance = bal; issueDate = issue; maturityDate = issue.plusYears(1); } public void setCertNum(String n) { certNum = n; } public void setName(String name) { lastName = name; } public void setBalance(double bal) { balance = bal; } public void issueDate(LocalDate date) { issueDate = date; } public String getCertNum() { return certNum; } public String getName() { return lastName; } public double getBalance() { return balance; } public LocalDate getIssueDate() { return issueDate; } public LocalDate getMaturityDate() { return maturityDate; } }
    import javax.swing.*; import java.time.*; public class CertOfDepositArray { public static void main(String[] args) { final int MAX = 5; CertOfDeposit[] certs = new CertOfDeposit[MAX]; int x; String certNum; String name; double balance; String entryString; int mo, da, yr; LocalDate issueDate; for(x = 0; x < MAX; ++x) { certNum = JOptionPane.showInputDialog(null, "Enter certificate number"); name = JOptionPane.showInputDialog(null, "Enter last name of owner"); entryString = JOptionPane.showInputDialog(null, "Enter balance"); balance = Double.parseDouble(entryString); entryString = JOptionPane.showInputDialog(null, "Enter month of issue"); mo = Integer.parseInt(entryString); entryString = JOptionPane.showInputDialog(null, "Enter day of issue"); da = Integer.parseInt(entryString); entryString = JOptionPane.showInputDialog(null, "Enter year of issue"); yr = Integer.parseInt(entryString); issueDate = LocalDate.of(yr, mo, da); certs[x] = new CertOfDeposit(certNum, name, balance, issueDate); } for(x = 0; x < MAX; ++x) display(certs[x], (x + 1)); } public static void display(CertOfDeposit cd, int num) { JOptionPane.showMessageDialog(null,"Certificate " + num + "\nName: " + cd.getCertNum() + " " + cd.getName() + " Balance: $" + cd.getBalance() + "\nIssued: " + cd.getIssueDate() + "\nMatures: " + cd.getMaturityDate()); } }
  7. In the exercises in Chapter 6, you created a class named Purchase. Each Purchase contains an invoice number, amount of sale, amount of sales tax, and several methods. Now, write a program that declares an array of five Purchase objects and prompt a user for their values. As each Purchase object is created, continuously prompt until the user enters an invoice number between 1000 and 8000 inclusive and a non-negative sale amount. Prompt the user for values for each object and then display all the values. Save the file as PurchaseArray.java.

    import java.util.*; public class PurchaseArray { public static void main(String[] args) { Purchase[] purchases = new Purchase[5]; int num; double amount; String entry; Scanner input = new Scanner(System.in); int x; final int LOW = 1000, HIGH = 8000; for(x = 0; x < purchases.length; ++x) { purchases[x] = new Purchase(); System.out.print("Enter invoice number >> "); num = input.nextInt(); while(num <= LOW || num >= HIGH) { System.out.println("Invoice number must be between " + LOW + " and " + HIGH); System.out.print("Enter invoice number >> "); num = input.nextInt(); } System.out.print("Enter sale amount >> "); amount = input.nextDouble(); while(amount < 0) { System.out.print("Enter sale amount greater than or equal to 0 >> "); amount = input.nextDouble(); } purchases[x].setInvoiceNumber(num); purchases[x].setSaleAmount(amount); } System.out.println("\nSummary of purchases:"); for(x = 0; x < purchases.length; ++x) purchases[x].display(); } }
    1. In the exercises in Chapter 6, you created an application named DrugTests that produces a list of randomly selected employees who will be tested each week for the next 52 weeks. Now modify the program to include a count and display of the number of times each employee is selected. Also display a list of employee numbers that never were selected for testing. Save the program as DrugTests2.java.

      public class DrugTests2 { public static void main(String[] args) { int testedEmployee; int week; final int WEEKS = 52; final int EMPLOYEES = 30; int[] counts = new int[EMPLOYEES]; int countNeverTested = 0; int x; for(week = 1; week <= WEEKS; ++week) { testedEmployee = 1 + (int) (Math.random() * EMPLOYEES); System.out.print("week " + week + " Emp # " + testedEmployee + " "); if(week % 4 == 0) System.out.println(); counts[testedEmployee - 1]++; } for(x = 0; x < EMPLOYEES; ++x) { System.out.print("Employee #" + (x + 1) + " is tested " + counts[x] + " time(s). "); if((x + 1) % 3 == 0) System.out.println(); } System.out.println("List of employees never tested during the year:"); for(x = 0; x < EMPLOYEES; ++x) { if(counts[x] == 0) { countNeverTested++; System.out.print("Emp #" + (x + 1) + " "); } } if(countNeverTested == 0) System.out.println("All employees were tested at least once"); } }
    2. When a series of random numbers is generated, it is quite common for the same number to be selected consecutively multiple times. Although duplicates happen in randomized lists, humans tend to see such repetition as “unfair.” Modify the DrugTests2 class so that if an employee number is selected immediately after it was already selected, a new number is selected for the week. Also display a message explaining that a new number is being selected. Save the file as DrugTests3.java

      public class DrugTests3 { public static void main(String[] args) { int testedEmployee; int week; final int WEEKS = 52; final int EMPLOYEES = 30; int[] counts = new int[EMPLOYEES]; int countNeverTested = 0; int x; int previousEmployee = -1; for(week = 1; week <= WEEKS; ++week) { testedEmployee = 1 + (int) (Math.random() * EMPLOYEES); if(testedEmployee == previousEmployee) { week--; System.out.println("Employee #" + testedEmployee + " was selected two weeks in a row -- making new selection"); } else { System.out.print("week " + week + " Emp # " + testedEmployee + " "); if(week % 4 == 0) System.out.println(); counts[testedEmployee - 1]++; previousEmployee = testedEmployee; } } for(x = 0; x < EMPLOYEES; ++x) { System.out.print("Employee #" + (x + 1) + " is tested " + counts[x] + " time(s). "); if((x + 1) % 3 == 0) System.out.println(); } System.out.println("List of employees never tested during the year:"); for(x = 0; x < EMPLOYEES; ++x) { if(counts[x] == 0) { countNeverTested++; System.out.print("Emp #" + (x + 1) + " "); } } if(countNeverTested == 0) System.out.println("All employees were tested at least once"); } }