Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import java.text.DecimalFormat;
- public class Commission
- {
- public static void main ( String [] args )
- {
- Scanner keyboard = new Scanner(System.in);
- String employeeName;
- double plansSold, salary = 0, receivedCommission = 0, total = 0;
- final double lowCommission = 0.005, medCommission = 0.0075, hiCommission = 0.01;
- int hoursWorked;
- System.out.print("What is the employee's name?");
- employeeName = keyboard.nextLine();
- System.out.print("How many hours worked?");
- hoursWorked = keyboard.nextInt();
- System.out.print("Enter total value of monthly plans sold today: ");
- plansSold = keyboard.nextDouble();
- salary = hoursWorked * 10;
- if(plansSold <= 1000)
- {
- receivedCommission = plansSold * lowCommission;
- }
- else if(plansSold > 1000 && plansSold <= 2000)
- {
- receivedCommission = plansSold * medCommission;
- }
- else if(plansSold > 2000)
- {
- receivedCommission = plansSold * hiCommission;
- }
- total = receivedCommission + salary;
- System.out.printf("%10s%10s%10s%10s", "Hours", "Salary", "Comm", "Total\n");
- System.out.printf("%10d%10.1f%10.1f%10.1f", hoursWorked, salary, receivedCommission, total);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement