×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Java
Posted by: chris knapp
Added: Jun 17, 2014 11:17 PM
Modified: Jun 18, 2014 12:42 AM
Views: 1777
Tags: no tags
  1. //~--- JDK imports ------------------------------------------------------------
  2.  
  3. import java.text.DecimalFormat;
  4.  
  5. import javax.swing.JOptionPane;
  6.  
  7. public class CommissionCalculator {
  8.  
  9.     /**
  10.      *
  11.      * @param args the command line arguments
  12.      */
  13.     public static void main(String[] args) {
  14.         String input;
  15.  
  16.         // Input of user
  17.         double salary;        // This is the annual sales value
  18.         double rate;          // This is the commission rate
  19.         double commission;    // This is the amount of commission made
  20.         double pay;           // Salesperson's pay
  21.         double sales;         // annual sales
  22.         double incentive;     // sales incentive
  23.         DecimalFormat dollar = new DecimalFormat("#,##0.00");
  24.         DecimalFormat percent = new DecimalFormat("##0.0%");
  25.  
  26.         input = JOptionPane.showInputDialog("Enter the annual salary.");
  27.         salary = Double.parseDouble(input);
  28.         input = JOptionPane.showInputDialog("Enter current commission rate.");
  29.         rate = Double.parseDouble(input);
  30.         input = JOptionPane.showInputDialog("Enter the current sales target");
  31.         sales = Double.parseDouble(input);
  32.         commission = rate * salary;
  33.         pay = commission + salary;
  34.         JOptionPane.showMessageDialog(null,
  35.                 "Commission rate is" + percent.format(rate) + ".The amount of pay is $"
  36.                 + dollar.format(pay));
  37.         {
  38.  
  39.             /* if (sales>=(.80*sales)&&sales<=120,000) */
  40.             incentive = (.75 * sales);
  41.  
  42.             /* else if(sales>120,000) */
  43.             incentive = (1.25 * .75 * sales);
  44.         }
  45.     }
  46. }
  47.  
  48.  
  49. //~ Formatted by Jindent --- http://www.jindent.com
  50.