Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static String[] retirement() {
- Scanner scan = new Scanner(System.in);
- String fileName = scan.nextLine(); //"D:\\java.txt"; // zczytaj se skanerem
- ArrayList<String> result = new ArrayList<String>();
- try {
- scan = new Scanner(new FileReader(fileName));
- while(scan.hasNextLine()) {
- String line = scan.nextLine();
- String[] data = line.split(" ");
- if(data.length == 4) {
- String gender = data[3];
- int age = 2017 - Integer.parseInt(data[2]);
- if((gender.equals("M") && age >= 65) || (gender.equals("K") && age >= 60)) {
- result.add(data[1] + " " + data[0]);
- }
- }
- }
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- }
- scan.close();
- return result.toArray(new String[0]);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement