Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class HWK5_Taylen_Schmaltz {
- /**
- * @throws java.io.IOException
- */
- public static int empIndex = 0;
- private static final String FILE_PATH = "C:\\Users\\Admin\\IdeaProjects\\hw\\src\\acmeEgr.txt";
- public static void main(String[] args) throws FileNotFoundException {
- Employee[] employees = new Employee[50];
- Scanner scanner = new Scanner(new File(FILE_PATH));
- while (scanner.hasNext()) {
- String firstName = scanner.nextLine();
- String lastName = scanner.nextLine();
- int departmentId = Integer.parseInt(scanner.nextLine());
- employees[empIndex++] = new Employee(firstName, lastName, departmentId);
- }
- printAll(employees);
- printDepartment("IT", employees);
- printLocation("Rochester Hills", employees);
- }
- public static void printAll(Employee[] ppl) {
- for (int i = 0; i < empIndex; i++) {
- System.out.println("Name: " + ppl[i].getName());
- System.out.println("Department: " + ppl[i].getDept());
- System.out.println("location: " + ppl[i].getLocation());
- }
- System.out.println("-----------------------");
- }
- public static void printDepartment(String title, Employee[] ppl) {
- System.out.println("Department: " + title);
- for (int i = 0; i < empIndex; i++) {
- if(ppl[i].getDept().equals(title)) {
- System.out.println("Name: " + ppl[i].getName());
- System.out.println("location: " + ppl[i].getLocation());
- }
- }
- System.out.println("-----------------------");
- }
- public static void printLocation(String loc, Employee[] ppl) {
- System.out.println("Location: " + loc);
- for (int i = 0; i < empIndex; i++) {
- if(ppl[i].getLocation().equals(loc)) {
- System.out.println("Name: " + ppl[i].getName());
- System.out.println("location: " + ppl[i].getDept());
- }
- }
- System.out.println("-----------------------");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement