Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners Need someone to check and modify my simple code
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Tapas
Need someone to check and modify my simple code
1 Answer(s)      5 years and 11 months ago
Posted in : Java Beginners



Advertisement
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


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 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 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
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 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
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
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
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 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
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 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
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
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
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
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
Run a simple EJB code
Run a simple EJB code  I found the code this. However, as I have no idea with EJB, I can't understand how to run it. Can anybody help me by giving... is acceptable). Thanks.   Please visit the following link: Simple EJB
Run a simple EJB code
Run a simple EJB code  I found the code this. However, as I have no idea with EJB, I can't understand how to run it. Can anybody help me by giving... is acceptable). Thanks.   Please visit the following link: Simple EJB
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
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
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
Simple ATM Java Code...
Simple ATM Java Code...  You are required to write a Graphical User Interface that simulates an ATM by building on the program you wrote.... It's a college assignment and needs to be written with the least amount of code
Simple Java applet that need usernam, password and textfield.
Simple Java applet that need usernam, password and textfield.  Hi. Anyone can help me on this matter: I need to create a small application that require user to login by username and password. After login, they should meet
Can someone review my script for an apparent parsing error? -it isn't quite finished yet, but I want to fix error first
Can someone review my script for an apparent parsing error? -it isn't quite finished yet, but I want to fix error first   import java.util.Scanner; class historyquiz{ public static void main(String args
 

 

 

DMCA.com