Online Training Spring Hibernate Training in Delhi R Programming Training Course Big Data and Hadoop Training Java Training  
 

Need someone to check and modify my simple code

Ads

 
 

Share on Google+Share on Google+

Tapas
Need someone to check and modify my simple code
1 Answer(s)      8 years ago
Posted in : Java Beginners
Ads
View Answers

April 13, 2009 at 4:54 PM


Hi Friend,

You can use following code:

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class PayRoll extends JFrame
{

final double withHolding = .15 ;
JButton Calculate;
JPanel panel;
JLabel label1,label2;
final JTextField text1,text2;
public PayRoll(){
label1 = new JLabel();
label1.setText("Enter the no. of working hours:");
text1 = new JTextField(20);
label2 = new JLabel();
label2.setText("Enter wage per hour:");
text2 = new JTextField(20);
Calculate=new JButton("Calculate");

panel=new JPanel(new GridLayout(3,2));
panel.add(label1);
panel.add(text1);
panel.add(label2);
panel.add(text2);
panel.add(Calculate);
add(panel,BorderLayout.CENTER);
setTitle("FORM");

Calculate.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae){
String value1=text1.getText();
String value2=text2.getText();
try{
double hoursWorked=Double.parseDouble(value1);
double wagePerHour=Double.parseDouble(value2);
double grossPay = wagePerHour * hoursWorked;
double tax = grossPay * withHolding;
double netPay=grossPay-tax;

JOptionPane.showMessageDialog(null, "Gross Pay is: "+grossPay);
JOptionPane.showMessageDialog(null, "Withholding tax of 15% on GP is: "+tax);
JOptionPane.showMessageDialog(null, "Net Pay is: "+netPay);
}
catch(Exception e){

JOptionPane.showMessageDialog(null, "Enter numeric value");
}
}
});
}
public static void main(String[] args)
{
PayRoll frame=new PayRoll();
frame.setVisible(true);
frame.pack();
}
}
Thanks

Ads









Related Tutorials/Questions & Answers:
Need someone to check and modify my simple code - Java Beginners
Need someone to check and modify my simple code   How to write a class that contains Variables that hold hourly rate of pay, number of hours...); } }   Hi Friend, You can use following code: import
need someone to do/help with code
need someone to do/help with code  i need someone to do a code for me. It is a restaurant menu that displays a list of 10 food items. A customer..., along with the number of items sold..please help did a code 500 times cant
Advertisements
Please help me to modify my java code from php code
Please help me to modify my java code from php code  i want to covert this php code int java/JSP . if (isset($_POST['orders'])) { $orders...]); $array[] = $item[1]; } } I tried like this (see below JSP code
Please help me to modify my java code from php code
Modify Java code from PHP Code  i want to covert this php code int...]; } } I tried like this (see below JSP code) ... but this is not giving me the exact result as the above PHP code is giving. So please help me to convert
Need simple java code to start and stop the remote windows service.
Need simple java code to start and stop the remote windows service.  Hi, I Need simple java code to start and stop the remote windows service... is running on Server A,I want to close that service i.e notepad.exe from my remote
need someone do it for me plz..people
need someone do it for me plz..people  write an application that displays a menue of three items in a restaurant as follows: 1.Cheeseburger 4.99.... modify the application in Exercise above so that if the user makes a menu
Need Sample code To check the Windows services status is up or down in Linux mechine
Need Sample code To check the Windows services status is up or down in Linux mechine  Hi, I did code to check the windows services are up or down... is up or down ,this has to check that in linux with simple standlon java
How can i modify my account in roseindia
How can i modify my account in roseindia  Presently am not using my gmail id. I have to modify my roseindia account. Please send the answer to following mail id
need help for writting code in struts action class for check boxes and radio buttons - Struts
need help for writting code in struts action class for check boxes and radio buttons  Hello frnds, i need help from u esteemed and talented people.iwould like to write code in struts action class for check boxes and radio
please check my code is wrong or ok.it was not work .this is form validation in javascript using jsf page
please check my code is wrong or ok.it was not work .this is form validation in javascript using jsf page  <p>?xml version='1.0' encoding='UTF-8' ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN
Need an example of basic code.
Need an example of basic code.   Im working on an art project that I... simple so I was hoping java would look more impressive. So I just need a visual of the building blocks of my idea so if someone could provide an example I would
Need an example of basic code.
Need an example of basic code.   Im working on an art project that I... simple so I was hoping java would look more impressive. So I just need a visual of the building blocks of my idea so if someone could provide an example I would
Need an example of basic code.
Need an example of basic code.   Im working on an art project that I... simple so I was hoping java would look more impressive. So I just need a visual of the building blocks of my idea so if someone could provide an example I would
Need help with my project
Need help with my project  Uses a while loop to perform the following steps: -Prompt the user to input two integers: firstNum and secondNum where... line in the file in the format yyyy-mm-dd hh:mm:ss.   The given code
PLZ Need some help on the 2nd part of this question...Someone please help !!!!
PLZ Need some help on the 2nd part of this question...Someone please help !!!!  write an application that displays a menue of three items... as FastFood.java B. modify the application in Exercise above so that if the user makes
I need help on my Java code.... please please help me out!?
I need help on my Java code.... please please help me out!?  Well my... in the file. Also it should be displayed on the screen. However my code doesn't display... need a part of the code thats fixed if possible! Heres is the code: import
need of code
need of code  howto convert greyscale image to binary image in java
need code
need code  Create Vehicle having following attributes: Vehicle No., Model, Manufacturer and Color. Create truck which has the following additional... is the required code: import java.util.*; class Vehicle { int
need code
need code  Create Vehicle having following attributes: Vehicle No., Model, Manufacturer and Color. Create truck which has the following additional... is the required code: import java.util.*; class Vehicle { int
need code
need code  Create Vehicle having following attributes: Vehicle No., Model, Manufacturer and Color. Create truck which has the following additional... is the required code: import java.util.*; class Vehicle { int
check youtube iframe code
check youtube iframe code  I have a piece of code that checks the youtube embed code in this format: My PHP code looks like this now: //Check Embed Code $embedCode = $postData['embedCode
pls i need help with my assignment
pls i need help with my assignment  how to write a code that ask the user for the height of the triangle and prints the triangle using * eg if height is 3 it prints * and also using import java.util.Scanner
dojo check tree code - Ajax
dojo check tree code  Hi..Boss Thanks for ur site. it helped me so many times.. my problem is while trying to use dojo tree with check boxes facing some issues i tried with two examples but i failed to do that http
Solve my code
Solve my code  import javax.servlet.*; import javax.servlet.http.*; import java.sql.*; import java.io.*; public class ChangeDetails extends... is the mistake in this code! This is working only one record doesn't work
I need add my java program with a picture.
I need add my java program with a picture.  Good evng Frnds Friends i created 1 jar file in my desktop. I need add this program with 1 picture... creating 1 picture. Later the program adding code with that picture.. Any 1 plz
Need sample code
Need sample code  Need code for graph which shows the performance comparission of aprior algorithm and coherent rule algorithm.plz can any one help me i need in a week
need JSP Code.
need JSP Code.  **Hi I need JSP code for selling Products which are in Database. Please can any one help for this.URGENT... Thank You..! Abhijeet
Need a JSP CODE
Need a JSP CODE  *Hi I need JSP source code for selling products which are in database.. please can any one help me ..URGENT* Thank You
simple code - Java Beginners
simple code  to input a number and check wether it is prime or not and print its position in prime nuber series.  Hi friend, Code to help in solving the problem : import java.io.*; class PrimeNumber { public
Problem in my code - Development process
Problem in my code  Plz go thru this code. I want to check login and pwd with database. Backend MsAccess , Table name : Reg , Dsn Name: JJ While executing code am getting 404 error User Name Password
Need source code - Swing AWT
Need source code  Hai, I need a source code for developing the project, title is "Face Recognition" and the backend as My-sql.... Thanks & Regards