-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLab1AVidhyaMoorthy.java
More file actions
46 lines (38 loc) · 1.19 KB
/
Copy pathLab1AVidhyaMoorthy.java
File metadata and controls
46 lines (38 loc) · 1.19 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
35
36
37
38
39
40
41
42
43
44
45
46
import java.io.*;
import java.util.ArrayList;
public class Lab1AVidhyaMoorthy {
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
ArrayList<String> lines = new ArrayList<String>();
String fName = "lab1aVidhyaMoorthyData.txt";
FileReader fr = new FileReader(fName);
BufferedReader br = new BufferedReader(fr);
PrintWriter pw = new PrintWriter("lab1aVidhyaMoorthyOutput.txt");
String line;
while((line = br.readLine()) != null)
{
lines.add(line);
}
pw.write("firstName\tlastName\tupdatedSalary");
pw.write("\r\n");
for(String str:lines)
{
String[] words = str.split(" ");
String fname = words[1];
String lname = words[0];
double salary = Double.parseDouble(words[2]);
double pIncrease = Double.parseDouble(words[3]);
salary = salary+(salary*(pIncrease/100));
pw.format("%s\t\t%s\t\t%.2f",fname,lname,salary);
pw.write("\r\n");
}
/** for(int i=lines.size()-1;i>=0;i--)
{
fw.write(lines.get(i));
fw.write("\r\n");
}
*/
br.close();
pw.close();
}
}