I need to write a java program in Eclipse Indigo with the scenario that three em
ID: 3629795 • Letter: I
Question
I need to write a java program in Eclipse Indigo with the scenario that three employees in a company are up for a special pay increase. I am given a file, say Ch3_Ex7Data.text, with the following data:
Miller Andrew 65789.87 5
Green Sheila 75892.56 6
Sethi Amit 74900.50 6.1
Each input line consists of an employee’s last name, first name, current salary, and percent pay increase. For example, in the first input line, the last name of the employee is Miller, the last name is Andrew, the current salary is 65789.87, and the pay increase is 5%. The program that I need to write reads data from the specified file and stores the output in the file Ch3_Ex7Output.dat For each employee, the data must be output in the following form: firstName lastName updateSalary. Format the output of decimal numbers to two decimal places.
Explanation / Answer
please rate - thanks
notice .text is .txt not .text
import java.util.*;
import java.io.*;
public class FileInOut
{public static void main(String[] args)throws FileNotFoundException
{Scanner input=new Scanner(new File("Ch3_Ex7Data.txt"));
String first,last;
double salary,percent;
PrintStream output=new PrintStream(new File("Ch3_Ex7Output.dat"));
output.println("First Last updated salary");
while(input.hasNext())
{try
{
last=input.next();
first=input.next();
salary=input.nextDouble();
percent=input.nextDouble()/100;
output.printf("%s %s $%.2f",first,last,salary+salary*percent);
output.println();
}catch (InputMismatchException e){};
}
}
}