Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.File;
- import java.io.FileNotFoundException;
- import java.io.PrintWriter;
- import java.util.ArrayList;
- import java.util.Scanner;
- public class Program {
- public static void main(String[] args) {
- try {
- File inputFile = new File("data.txt");
- File outputFile = new File("dataout.txt");
- Scanner reader = new Scanner(inputFile);
- PrintWriter pw = new PrintWriter(outputFile);
- ArrayList<Student> stds = new ArrayList<Student>();
- int cnt = 0;
- while (reader.hasNextLine()) {
- String[] input = reader.nextLine().split(" ");
- stds.add(new Student(input[0], Integer.parseInt(input[1]), Double.parseDouble(input[2])));
- }
- for (Student s : stds) {
- if (s.getNumber() % 2 == 0) {
- pw.println(s);
- }
- }
- pw.close();
- reader.close();
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement