Question

In: Computer Science

Three employees in a company are selected for a pay increase. You are given a file...

Three employees in a company are selected for a pay increase. You are given a file (salaries.txt) that contains three lines. Each line in the file consists of an employee’s last name, first name, current salary, and percent pay increase. For example, in the first 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 file and stores the output in another file. The output data must be in the following format: FirstNameInitial lastName updatedSalary Format the output of decimal number to two decimal places. For example, the first line in the output may look like the following: A. Miller 69079.36 I want help to solve it on netbeans


java programing language

Solutions

Expert Solution

import java.io.BufferedReader;

import java.io.BufferedWriter;

import java.io.FileReader;

import java.io.FileWriter;

import java.io.IOException;

public class Main {

public static void main(String[] args) {

try (FileReader reader = new FileReader("salaries.txt");

BufferedReader br = new BufferedReader(reader)) {

String line;

while ((line = br.readLine()) != null) {

System.out.println(line);

String[] inputs = line.split(" ");

String lastName = inputs[0];

String firstName = inputs[1];

double salary = Double.parseDouble(inputs[2]);

double raise = Double.parseDouble(inputs[3]);

double newSalary = (1 + raise/100) * salary;

System.out.println(String.format("%c. %s %.2f\n", Character.toUpperCase(firstName.charAt(0)), lastName, newSalary));

try (FileWriter writer = new FileWriter("output.txt", true);

BufferedWriter bw = new BufferedWriter(writer)) {

bw.write(String.format("%c. %s %.2f\n", Character.toUpperCase(firstName.charAt(0)), lastName, newSalary));

} catch (IOException e) {

System.err.format("IOException: %s%n", e);

}

}

} catch (IOException e) {

System.err.format("error occurred while opening the file", e);

}

}

}


Related Solutions

Three employees in a company are up for a special pay increase. You are given a...
Three employees in a company are up for a special pay increase. You are given a file, say Ch3_Ex5Data.txt, 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 first name is Andrew, the current salary is 65789.87, and the pay...
Summary Three employees in a company are up for a special pay increase. You are given...
Summary Three employees in a company are up for a special pay increase. You are given a file, say Ch3_Ex5Data.txt, 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 first name is Andrew, the current salary is 65789.87, and the...
The Excel file BankData shows the values of the following variables for randomly selected 93 employees...
The Excel file BankData shows the values of the following variables for randomly selected 93 employees of a large bank. This real data set was used in a court lawsuit against discrimination.   Let = monthly salary in dollars (SALARY), = years of schooling at the time of hire (EDUCAT), = number of months of previous work experience (EXPER), = number of months that the individual was hired by the bank (MONTHS), = dummy variable coded 1 for males and 0...
The Excel file BankData shows the values of the following variables for randomly selected 93 employees...
The Excel file BankData shows the values of the following variables for randomly selected 93 employees of a large bank. (A very similar data set was used in a court lawsuit against discrimination.)   Let = monthly salary in dollars (SALARY), = years of schooling at the time of hire (EDUCAT), = number of months of previous work experience (EXPER), = number of months that the individual was hired by the bank (MONTHS), = dummy variable coded 1 for males and...
The Excel file Salary reports the monthly salaries for 93 randomly and independently selected employees of...
The Excel file Salary reports the monthly salaries for 93 randomly and independently selected employees of a bank; there are 32 salaries of male employees and 61 salaries of female employees.   Let um = the mean monthly salary for all male bank employees, and uf = the mean monthly salary for all female bank employees. Your objective is to find some evidence of um > uf, that is, the female employees are discriminated against. Provide descriptive statistical summaries of the...
Develop a Java application that determines the gross pay for each of three employees.
(Salary Calculator) Develop a Java application that determines the gross pay for each of three employees. The company pays straight time for the first 40 hours worked by each employee and time and a half for all hours worked in excess of 40. You’re given a list of the employees, their number of hours worked last week and their hourly rates. Your program should input this information for each employee, then determine and display the employee’s gross pay. Use class...
Problem 24-1: Compute gross pay. Using the information given for Archway Company, compute the employees' gross...
Problem 24-1: Compute gross pay. Using the information given for Archway Company, compute the employees' gross pay for the payroll week ending July 14 and the year-to-date gross pay as of July 14. Employees receive time-and-a-half for overtime hours (fill in the shaded areas). Employee Number Hours Worked Pay per Hour Gross Pay Year-to-Date Gross Pay Regular Overtime As of July 7 As of July 14 1 38 0 $16.80 $23,200.80 2 40 0 22.40 29,269.60 3 40 2 19.20...
Is it Fair to Dock Employees’ Pay for Bathroom Breaks? Consider a company whose employees include...
Is it Fair to Dock Employees’ Pay for Bathroom Breaks? Consider a company whose employees include both smokers and nonsmokers. The smokers take numerous paid smoking breaks, while the nonsmokers do not. Is there an ethical issue here? Discuss.
. In your small manufacturing company you prefer to pay the employees under Merricks differential piece-...
. In your small manufacturing company you prefer to pay the employees under Merricks differential piece- rate system. There are three employees; Rahman, Ali, and Mahmood who produced 85 units, 69 units and, 35 units respectively in one particular day. How much would you pay your employees if you have fixed 0.500 Baisa per unit as piece rate, standard output as 50 units per day? The employees normally work for 8 hours a day.
Ms.salma is yet to pay the salaries to her employees of last three months. Write a...
Ms.salma is yet to pay the salaries to her employees of last three months. Write a ahort note on accrued expenses with literature review and by providing examples.?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT