BaşlayınÜcretsiz başlayın

Employee salary analysis

You're analyzing employee data for a tech company. The HR department needs to adjust salaries to reflect a 10% raise for all employees. Your task is to transform each salary value and add the results as a new column.

The Tablesaw library has been imported, and employees.csv contains the Name, Department, Salary, and Bonus columns.

Bu egzersiz, kursun bir parçasıdır

Importing Data in Java

Kursa Göz Atın

Egzersiz talimatları

  • Apply a transformation to calculate each employee's salary increased by 10%.
  • Add the new adjusted salary column to the table.

Uygulamalı etkileşimli egzersiz

Bu egzersizi bu örnek kodu tamamlayarak deneyin.

public class EmployeeSalary {
    public static void main(String[] args) {
        Table employees = Table.read().csv("employees.csv");
        
        // Apply transformation for 10% increase
        DoubleColumn adjustedSalary = employees.intColumn("Salary")
            .asDoubleColumn()
            .____(salary -> salary * ____);
        
        // Add new column to table
        employees.____(adjustedSalary.setName("AdjustedSalary"));
        
        System.out.println("Employee Salary Analysis:");
        System.out.println(employees.first(5));
    }
}
Kodu Düzenle ve Çalıştır