- Home
- Chapter 1 - Object Oriented Programming Concepts
- Object Oriented Programming Concepts
- Multiple Choice Questions
- State whether the given statements are True or False
- Assignment Questions
- Chapter 2 - Introduction to Java
- Introduction to Java
- Multiple Choice Questions
- Assignment Questions
- Chapter 3 - Values and Data Types
- Values and Data Types
- Multiple Choice Questions
- State whether the given statements are True or False
- Assignment Questions
- Chapter 4 - Operators in Java
- Operators in Java
- Multiple Choice Questions
- State whether the given statements are True or False
- Assignment Questions
- Chapter 5 - User-Defined Methods
- User-Defined Methods
- Multiple Choice Questions
- State whether the given statements are True or False
- Assignment Questions
- Chapter 6 - Input in Java
- Input in Java
- Multiple Choice Questions
- Assignment Questions and Programs
- Chapter 7 - Mathematical Library Methods
- Mathematical Library Methods
- Multiple Choice Questions
- Assignment Questions
- Chapter 8 - Conditional Constructs in Java
- Conditional Constructs in Java
- Multiple Choice Questions
- Assignment Questions and Programs
- Chapter 9 - Iterative Constructs in Java
- Iterative Constructs in Java
- Multiple Choice Questions
- State whether the given statements are True or False
- Assignment Questions and Programs
- Chapter 10 - Nested for loops
- Nested for loops
- Assignment Questions and Programs
- Chapter 11 - Constructors
- Constructors
- Multiple Choice Questions
- Assignment Questions and Programs
- Chapter 12 - Library Classes
- Library Classes
- Multiple Choice Questions
- Assignment Questions
- Chapter 13 - Encapsulation and Inheritance
- Library Classes
- Multiple Choice Questions
- Assignment Questions
- Chapter 14 - Arrays
- Library Classes
- Multiple Choice Questions
- Assignment Questions
- Chapter 15 - String Handling
- Library Classes
- Multiple Choice Questions
- Assignment Questions
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.00Output 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
