-
Notifications
You must be signed in to change notification settings - Fork 88
Expand file tree
/
Copy pathMain.java
More file actions
34 lines (31 loc) · 1.48 KB
/
Main.java
File metadata and controls
34 lines (31 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package org.example;
import java.io.FileWriter;
import java.util.Scanner;
import java.io.IOException;
public class Main {
public static void main(String[] args) throws IOException {
Employee[] employees = new Employee[10];
employees[0] = new Employee("Ali", "[email protected]", 25, 1500);
employees[1] = new Employee("Veli", "[email protected]", 30, 2000);
employees[2] = new Employee("Aysel", "[email protected]", 28, 1800);
employees[3] = new Employee("Murad", "[email protected]", 35, 2500);
employees[4] = new Employee("Nigar", "[email protected]", 22, 1200);
employees[5] = new Employee("Rauf", "[email protected]", 40, 3000);
employees[6] = new Employee("Leyla", "[email protected]", 27, 1700);
employees[7] = new Employee("Tural", "[email protected]", 33, 2200);
employees[8] = new Employee("Sabina", "[email protected]", 29, 1900);
employees[9] = new Employee("Kamran", "[email protected]", 31, 2100);
try(FileWriter writer=new FileWriter("employees.txt")){
for(int i=0;i<employees.length;i++){
writer.write(employees[i].getName()+",");
writer.write(employees[i].getEmail()+",");
writer.write(employees[i].getAge()+",");
writer.write(employees[i].getSalary()+"\n");
}
System.out.println("Employees have been created");
}
catch(IOException e){
System.out.println("Error while writing to file");
}
}
}