Lab 6 Pay Increase Several employees in a company are up for a special pay incre
ID: 3624091 • Letter: L
Question
Lab 6 Pay IncreaseSeveral employees in a company are up for a special pay increase. You are given a file, say SpecialIncrease.txt, with data in the following format:
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 first name is Andrew, the current salary is 65789.87, and the pay increase is 5%. Write a program that reads data from the specified file and stores the output in the file PayIncrease.txt. For each employee, the data must be output in the following form: firstName lastName updatedSalary. Format the output of decimal numbers to two decimal places.
ADDITIONAL FILES:
NONE
TURN IN:
Java code
Design
Explanation / Answer
please rate - thanks
import java.util.*;
import java.io.*;
public class FileInOut
{public static void main(String[] args)throws FileNotFoundException
{Scanner input=new Scanner(new File("SpecialIncrease.txt"));
String first,last;
double salary,percent;
PrintStream output=new PrintStream(new File("PayIncrease.txt"));
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){};
}
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.