Java COMPUTE total bonuses with swing tools-source code (expandable)

Source: Internet
Author: User

Title: The bonuses awarded by the Enterprise are based on the profit commission.

* If Profit (I) is less than or equal to $100,000, the bonus may be raised by 10%;
* Between 100,000 and 200,000, less than 100,000 yuan in the portion of 10% commission, higher than the portion of 100,000 yuan, can be a commission of 7.5%;
* Between 200,000 and 400,000, higher than 200,000 yuan of the portion, can commission 5%;
* Between 400,000 and 600,000, higher than 400,000 yuan of the portion, can commission 3%;
* Between 600,000 and 1 million, higher than 600,000 yuan of the portion, can commission 1.5%;
* Above $1 million, the portion of more than $1 million is 1% Commission.

* Enter the current month profit from the keyboard, the total bonus should be issued?



Package com.bj.WageCalculation;


Import Java.awt.BorderLayout;
Import java.awt.event.ActionEvent;
Import Java.awt.event.ActionListener;
Import Javax.swing.JButton;
Import Javax.swing.JFrame;
Import Javax.swing.JPanel;
Import Javax.swing.JTextField;
/**
* 1. Setting the Window component
* 2. Defining events
* 3. Presentation of data
* @author Zy
*
*/


public class Wagecalculation {
public static void Main (string[] args) {//Main method
Wagecalculation ();
}

/**
* Set Window Components
*/
public static void Wagecalculation () {
JFrame frame=new JFrame ("Calculate bonus");//define a window container
JPanel jpanel=new JPanel ();//define a panel container
Final JTextField jtext=new JTextField (10);//define a text input box, length 10
JButton jbutton=new JButton ("bonus");//define a button

Frame.add (JPanel);//window container add panel
Jpanel.add (Jtext,borderlayout.north);//Panel container add text input box
Jpanel.add (JButton);//Panel container Add button

Frame.setsize (300,200);//Set window size
Frame.setvisible (TRUE);//Settings window visible
Frame.setresizable (false);//Set window size is not variable
Frame.setdefaultcloseoperation (frame. Exit_on_close);//Close window, free memory

/**
* Define Events
*/

Jbutton.addactionlistener (new ActionListener () {
public void actionperformed (ActionEvent e) {
Double setwages = double.parsedouble (Jtext.gettext ());//Get text box data
Wages getwages=new Wages ();//Create Wages Class object
Double Wage=getwages.wages (setwages);//Wages method of calling Wages

Jtext.settext (wage+ "");//double data converted to string type and enter text box
}
});
}
}


Package com.bj.WageCalculation;
/**
*
* @author Zy
* Title: Bonuses awarded by the enterprise according to the profit commission.
* If Profit (I) is less than or equal to $100,000, the bonus may be raised by 10%;
* Between 100,000 and 200,000, less than 100,000 yuan in the portion of 10% commission, higher than the portion of 100,000 yuan, can be a commission of 7.5%;
* Between 200,000 and 400,000, higher than 200,000 yuan of the portion, can commission 5%;
* Between 400,000 and 600,000, higher than 400,000 yuan of the portion, can commission 3%;
* Between 600,000 and 1 million, higher than 600,000 yuan of the portion, can commission 1.5%;
* Above $1 million, the portion of more than $1 million is 1% Commission.
* Enter the current month profit from the keyboard, the total bonus should be issued?
*
*/
public class Wages {
public static void Main (string[] args) {
Wages (90000);
System.out.println (Wages (2000000));
}


public static double Wages (double wage) {

Double wagetotal = 0;

if (wage<100000) {
wagetotal=wage*0.1;
System.out.println ("=======" +wagetotal);
}else if (wage<200000 && wage>=100000) {
Wagetotal= (100000) *0.1+ (wage-100000) *0.075;
}else if (wage<400000 && wage>=200000) {
Wagetotal= (100000) *0.1+ (200000) *0.075+ (wage-200000) *0.05;
}else if (wage<600000 && wage>=400000) {
Wagetotal= (100000) *0.1+ (200000) *0.075+ (400000) *0.05+ (wage-400000) *0.03;
}else if (wage<1000000 && wage>=600000) {
Wagetotal= (100000) *0.1+ (200000) *0.075+ (400000) *0.05+ (600000) *0.03+ (wage-600000) *0.015;
}else{
Wagetotal= (100000) *0.1+ (200000) *0.075+ (400000) *0.05+ (600000) *0.03+ (1000000) *0.015+ (wage-1000000) *0.001;
}
return wagetotal;
}
}

Java COMPUTE total bonuses with swing tools-source code (expandable)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.