Important alert: (current site time 7/15/2013 12:09:01 PM EDT)
 

VB icon

Calculate Wages

Email
Submitted on: 3/20/2004 12:22:22 PM
By: Razie Mat Saman 
Level: Beginner
User Rating: Unrated
Compatibility: JavaScript
Views: 5325
author picture
(About the author)
 
     Can calculate the rate of wages per hour

 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
				
'**************************************
' Name: Calculate Wages
' Description:Can calculate the rate of wages per hour
' By: Razie Mat Saman
'
'This code is copyrighted and has' limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=4136&lngWId=14'for details.'**************************************

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class Wages extends JFrame implements ActionListener
{
private JLabel workL,payL,RM;
private JTextField input1,input2;
private JButton Calculate;
private JPanel panel1,panel2,panel3,panel4;
public Wages()
{
super("Calculate wages");
 workL = new JLabel("Working Hours");
 payL = new JLabel ("Total Of Payment");
 RM = new JLabel("RM",SwingConstants.RIGHT);
input1 = new JTextField();
input2 = new JTextField();
input2.setEditable(false);
Calculate = new JButton("Calculate");
Calculate.addActionListener(this);
panel1 = new JPanel();
panel1.setLayout(new GridLayout(1,2));
panel1.add(workL);
panel1.add(input1);
panel2 = new JPanel();
panel2.setLayout(new GridLayout(1,2));
panel2.add(payL);
panel2.add(input2);
panel3 = new JPanel();
panel3.setLayout(new GridLayout(1,1));
panel3.add(Calculate);
Container container = getContentPane();
container.setLayout(new GridLayout(3,1));
container.add(panel1);
container.add(panel2);
container.add(panel3);
this.pack();
this.setVisible(true);
}
public void actionPerformed(ActionEvent event)
{
int Input,value1,value2,value3,value4,value5,balance;
input2.setText("");
if(event.getSource()==Calculate); 
{
try{
Input=Integer.parseInt(input1.getText());
if(Input<=20)
{
value1=Input*3;
input2.setText("RM "+String.valueOf(value1));
}
else if (Input>=30 && Input<60)
{
value2=Input-30;
value3=((value2*6)+(20*3));
input2.setText("RM "+String.valueOf(value3));
}
else
{
value4=Input-50;
value5=((3*20)+(6*30)+(value4*10)); 
input2.setText("RM "+String.valueOf(value5));
}
}
catch(Exception e)
{
JOptionPane.showMessageDialog(this,"Invalid Parameter");
}
}
}
public static void main (String args[])
{
Wages application = new Wages();
application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}


Other 1 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.