![]() |
|
#1
|
||||
|
||||
|
I need some help with a bit of JAVA programming if anybody can help me.
I have a small programme and the last part of it requires me to have a way of working out commission earned based on total sales. The rate of commission is based on the following table of weekly sales. Weekly Sales total Commission made (%) £0 - £100 0 £101 - £200 2 £201- £300 5 £301- £500 10 £501+ 15 Here is the code I have, I just need to know how to write the code for the convert button to work out the commision based on a value put into the tempTextField and displayed in the commisionLabel as a value in £s. If I knew how to do the first 2 (0-100 and 101-200) then I could work out the rest myself. Code:
/*
*JFParts.java
*
* Created on 25 November 2008, 16:11
*/
/**
*
* @author Simon Richardson
*/
public class JFParts extends javax.swing.JFrame {
/** Creates new form JFParts */
public JFParts() {
initComponents();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
textField = new javax.swing.JTextField();
textField2 = new javax.swing.JTextField();
nameLabel = new javax.swing.JLabel();
weeklysalesLabel = new javax.swing.JLabel();
convertButton = new javax.swing.JButton();
commisionLabel = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("Commision Calculator");
textField2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
textField2ActionPerformed(evt);
}
});
nameLabel.setText("Name");
weeklysalesLabel.setText("Weekly Sales");
convertButton.setText("Convert");
convertButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
convertButtonActionPerformed(evt);
}
});
commisionLabel.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
commisionLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
commisionLabel.setText("% Commision");
commisionLabel.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(layout.createSequentialGroup()
.addComponent(textField2, javax.swing.GroupLayout.PREFERRED_SIZE, 8, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(weeklysalesLabel))
.addGroup(layout.createSequentialGroup()
.addComponent(textField, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(nameLabel))
.addComponent(convertButton)
.addComponent(commisionLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap(129, Short.MAX_VALUE))
);
layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {textField, textField2});
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(textField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(nameLabel))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(weeklysalesLabel)
.addComponent(textField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(convertButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(commisionLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(23, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
private void textField2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void convertButtonActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new ABCMotors().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JLabel commisionLabel;
private javax.swing.JButton convertButton;
private javax.swing.JLabel nameLabel;
private javax.swing.JTextField textField;
private javax.swing.JTextField textField2;
private javax.swing.JLabel weeklysalesLabel;
// End of variables declaration
}
__________________
Always Wear Your Helmet!
|
|
#2
|
||||
|
||||
|
ask insurgo he might know.
__________________
![]() |
|
#3
|
||||
|
||||
|
Insurgo is your man Gin. Don't think he is up to scratch on JAVA though. Drop him an email kyle.colyer@gmail.com
__________________
![]() Penguin21189 since January 2003© The Bodman since January 1989© |
![]() |
| Thread Tools | |
| Display Modes | |
|
|