49CMD.com Forums
 

Go Back   49CMD.com Forums > General > The Furnace > Tech Room
Home Register Awards Leaderboard Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
  #1  
Old 11-26-2008, 09:41 AM
Ginjasy's Avatar
Ginjasy Ginjasy is offline
Level 8
 
Join Date: Mar 2007
Location: Somerton, Somerset
Posts: 241
Send a message via MSN to Ginjasy Send a message via Yahoo to Ginjasy Ginjasy
24 Month Service: Be a member of the clan for over 24 months. - Issue reason:  40,000 Gamerscore: Have 40,000GS on their Gamertag. - Issue reason:  ChocoNET Medal: Given to those members consistently proving themselves to have a less than stellar connection. - Issue reason: [Earned in: DVDX - COD4 | Thur 07 Feb 08 - 8:30pm] 
Default Can anybody code JAVA

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!
Reply With Quote
  #2  
Old 11-26-2008, 02:07 PM
RED's Avatar
RED RED is offline
Level 16
 
Join Date: Mar 2007
Location: Middlesbrough
Posts: 730
Send a message via MSN to RED o0 RED 0o
30,000 Gamerscore: Have 30,000GS on their Gamertag. - Issue reason:  Forumer Award: Make 500 posts on the 49 Commando Forums! - Issue reason:  24 Month Service: Be a member of the clan for over 24 months. - Issue reason:  
Default

ask insurgo he might know.
__________________
Reply With Quote
  #3  
Old 12-01-2008, 10:32 PM
Penguin21189's Avatar
Penguin21189 Penguin21189 is offline
Level 4
 
Join Date: Dec 2007
Location: Leicester
Posts: 57
Send a message via MSN to Penguin21189 Penguin21189
Default

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©
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT. The time now is 06:28 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.