Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | IT Developer <?php echo $page_title; ?>
IT Developer

Conditional Constructs in Java

Chapter 9

Conditional Constructs in Java

Class 9 - Logix Kips ICSE Computer Applications with BlueJ


Share with a Friend

Java Programs - Employee Wage Calculation with Commission Slabs


Employees at Arkenstone Consulting earn the basic hourly wage of Rs.500. In addition to this, they also receive a commission on the sales they generate while tending the counter. The commission given to them is calculated according to the following table:

Total Sales

Commmision Rate

Rs. 100 to less than Rs. 1000

1%

Rs. 1000 to less than Rs. 10000

2%

Rs. 10000 to less than Rs. 25000

3%

Rs. 25000 and above

3.5%

Write a program in Java that inputs the number of hours worked and the total sales. Compute the wages of the employees.


import java.util.Scanner;

 

public class EmployeeWageCalculator {

    public static void main(String[] args) {

 

        Scanner sc = new Scanner(System.in);

 

        System.out.print("Enter number of hours worked: ");

        int hoursWorked = sc.nextInt();

 

        System.out.print("Enter total sales amount: ");

        double totalSales = sc.nextDouble();

 

        double hourlyWage = 500;

        double commissionRate;

 

        // Determine commission rate based on sales slabs

        if (totalSales >= 100 && totalSales < 1000) {

            commissionRate = 0.01;

        } else if (totalSales >= 1000 && totalSales < 10000) {

            commissionRate = 0.02;

        } else if (totalSales >= 10000 && totalSales < 25000) {

            commissionRate = 0.03;

        } else if (totalSales >= 25000) {

            commissionRate = 0.035;

        } else {

            commissionRate = 0.0;

        }

 

        double basicPay = hoursWorked * hourlyWage;

        double commission = totalSales * commissionRate;

        double totalWages = basicPay + commission;

 

        System.out.println("\n------ Employee Wage Details ------");

        System.out.printf("Basic Pay     : ₹%.2f%n", basicPay);

        System.out.printf("Commission    : ₹%.2f%n", commission);

        System.out.printf("Total Wages   : ₹%.2f%n", totalWages);

 

        sc.close();

    }

}

Output

Output 1:

SAMPLE INPUT : Enter number of hours worked: 8 Enter total sales amount: 12000 SAMPLE OUTPUT : ------ Employee Wage Details ------ Basic Pay : ₹4000.00 Commission : ₹360.00 Total Wages : ₹4360.00

Output 2:

SAMPLE INPUT : Enter number of hours worked: 6 Enter total sales amount: 30000 SAMPLE OUTPUT : ------ Employee Wage Details ------ Basic Pay : ₹3000.00 Commission : ₹1050.00 Total Wages : ₹4050.00

Explanation

1. Input

  • Number of hours worked
  • Total sales amount

2. Basic Pay Calculation

Basic Pay = Hours Worked × 500

 

double basicPay = hoursWorked * hourlyWage;

3. Commission Calculation

  • Commission rate is selected using an if–else ladder
  • Commission is calculated as:

Commission = Total Sales × Commission Rate

4. Total Wages

Total Wages = Basic Pay + Commission