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 8

Conditional Constructs in Java

Class 10 - Logix Kips ICSE Computer Applications with BlueJ


Share with a Friend

Java Program: Compute the wages of the Employees


26. 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 EmployeeWages {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

 

        int hoursWorked;

        double totalSales, commission = 0, wages;

 

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

        hoursWorked = sc.nextInt();

 

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

        totalSales = sc.nextDouble();

 

        // Calculate commission based on sales

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

            commission = 0.01 * totalSales;

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

            commission = 0.02 * totalSales;

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

            commission = 0.03 * totalSales;

        } else if (totalSales >= 25000) {

            commission = 0.035 * totalSales;

        }

 

        // Calculate total wages

        wages = (hoursWorked * 500) + commission;

 

        System.out.println("\nCommission Earned: Rs. " + commission);

        System.out.println("Total Wages: Rs. " + wages);

    }

}

Output

Sample Output 
Enter number of hours worked: 8
Enter total sales (Rs.): 12000

Commission Earned: Rs. 360.0
Total Wages: Rs. 4360.0

Explanation

  • Basic wage is calculated as:

                hoursWorked × 500

  • Commission is calculated based on the applicable sales slab.
  • Total wages =

              Basic Wage + Commission

  • if-else-if ladder is used to apply the correct commission rate.