Hope it helps ^_^The question wasn't clear, it would have been better if you had provided an example of how the output should be.I am printing the commission by taking sales as input._____________________________________import java.util.Scanner;
public class Salesman_Ki_Commission{
public static void main(String [] args){
Scanner sc = new Scanner(System.in);
double sales, commission = 0;
// Printing the useless commission-rate table
System.out.println("This program calculates the commission earned by the salesman by taking sales as input");
System.out.println("");
System.out.println("This is the rate of commission");
System.out.println(" Sales " + " Commission(%)");
System.out.println("Sales >= 100000 " + " 25% ");
System.out.println("Sales >= 80000 " + " 22% ");
System.out.println("Sales >= 60000 " + " 20% ");
System.out.println("Sales >= 40000 " + " 15% ");
System.out.println("Sales < 40000 " + " 12% ");
System.out.println("");
// Taking input from the user
System.out.print("Enter the name: ");
String name = sc.nextLine();
System.out.print("Enter the sales: ");
sales = sc.nextDouble();
// Most important part comes here
if (sales >= 100000)
commission = 0.25 * sales;
else if (sales >= 80000 && sales < 100000)
commission = 0.22 * sales;
else if (sales >=60000 && sales < 80000)
commission = 0.2 * sales;
else if (sales >= 40000 && sales < 60000)
commission = 0.15 * sales;
else
commission = 0.12 * sales;
// Printing the output
System.out.println("The total commission earned by " + name + ": " + commission);
}
}
_____________________________________
I added all the outputs to make the answer even lengthier (. ❛ ᴗ ❛.)Lengthy answers make me go brrrrrrrrrrrrrrrrrrrThe underlined part is the user-input
Output:(i)
This program calculates the commission earned by the salesman by taking sales as input
This is the rate of commission
Sales Commission(%)
Sales >= 100000 25%
Sales >= 80000 22%
Sales >= 60000 20%
Sales >= 40000 15%
Sales < 40000 12%
Enter the name: Shivu
Enter the sales: 100000
The total commission earned by Shivu: 25000.0
(ii)
This program calculates the commission earned by the salesman by taking sales as input
This is the rate of commission
Sales Commission(%)
Sales >= 100000 25%
Sales >= 80000 22%
Sales >= 60000 20%
Sales >= 40000 15%
Sales < 40000 12%
Enter the name: Shivu
Enter the sales: 80000
The total commission earned by Shivu: 17600.0
(iii)
This program calculates the commission earned by the salesman by taking sales as input
This is the rate of commission
Sales Commission(%)
Sales >= 100000 25%
Sales >= 80000 22%
Sales >= 60000 20%
Sales >= 40000 15%
Sales < 40000 12%
Enter the name: Shivu
Enter the sales: 60000
The total commission earned by Shivu: 12000.0
(iv)
This program calculates the commission earned by the salesman by taking sales as input
This is the rate of commission
Sales Commission(%)
Sales >= 100000 25%
Sales >= 80000 22%
Sales >= 60000 20%
Sales >= 40000 15%
Sales < 40000 12%
Enter the name: Shivu
Enter the sales: 40000
The total commission earned by Shivu: 6000.0
(v)
This program calculates the commission earned by the salesman by taking sales as input
This is the rate of commission
Sales Commission(%)
Sales >= 100000 25%
Sales >= 80000 22%
Sales >= 60000 20%
Sales >= 40000 15%
Sales < 40000 12%
Enter the name: Shivu
Enter the sales: 150
The total commission earned by Shivu: 18.0
_____________________________________Hope you liked this lengthy answer