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

 
 


Tapas
Need someone to check and modify my simple code
1 Answer(s)      4 years and a month ago
Posted in : Java Beginners

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 Pages:
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
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
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 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
modify program
modify program  Hi how could I modify this program so that if I say... yes only the user input for the code and quantity is displayed,thank you. address 1: address 2: address 3: post code: code: quantity: the is the program
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
Could someone Possibly help me with this
Could someone Possibly help me with this   think of a number... is guessed //check guess and output hint //guess is correct...(); } System.out.println("Correct!!!!!!!"); } } But when the code is run I do
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
Java--Xml Modify Node Value - Java Beginners
are trying to update a node, first you need to check whether it is text node or element...Java--Xml Modify Node Value  I have the following xml. test... of ,,and through NodeList. I wrote the follwoing code. package xml_handson; import
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
How to check a checkbox - Struts
How to check a checkbox  Hello Community, How can i check a checkbox... tags i am getting an error that the property "checked" is not defined. Can someone please help me with the syntax??  Hi friend, my checkbox
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
check
updated"); will the above code check if the user has entered value for empcode and password variables.Explain the code... code,String pass) { this.empcode=code; this.password
Need of JUnit
code faster while increasing quality. 2 JUnit is elegantly simple. It is less... and they check their own results and provide immediate feedback. There's no need...Need of JUnit  Hi sir, What makes JUnit better than other
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
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
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
Can someone help me with this?
Can someone help me with this?  I have this project and i dont know how to do it. Can someone help me? please? Write a java class named "PAMA" which define a main () method that performs simple arithmetic. (e.g. Add, Subtract
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
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
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 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
code need - Java Beginners
code need  hi i want to code doing for this. If i have enter the text file in my java project. example input is 1,2,3,4,5(it is in input text file...)  Hi Friend, Try the following code. We hope this will help you
need code for file browser
need code for file browser  hi, i need to write a code to browse the file in my computer using Jsp or java.. what is the code for file browser?   JSP Code for browsing: 1)page.jsp: <%@ page language="java" %>
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
this is my code java - Date Calendar
this is my code java  /* * NewJFrame.java * * Created on 11... NOT modify this code. The content of this method is * always regenerated...; jTextField1.setText(months); #### This My problem jTextField2.setText(days
Help for Check availability of user
Help for Check availability of user  I need the code for check availability of users in the database before login.I placed a button for Check Availability.Can it be done with this or ajax should be used
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
Need source code - Swing AWT
Need source code  Hai, I need a idea and code for developing the project "Face Recognition" with the backend as My-sql.... Thanks & Regards
A Simple program
A Simple program  Hi I have written the following code: class... required code: class FirstRectangle{ public int rectArea(int l,int b...; Thanks for the solution. Now its working. One more thing I need to ask
check box condition
check box condition  Hai, my application has two check box one for chart and another one for table.when We click chart check box download only... in my application..please help me
need coding
need coding  sir i need code for simple bank application in jsp please send it   sir i need the coding for simple bank application in jsp.   Please visit the following link: Jsp Bank Application
Simple problem to solve - JSP-Servlet
in next page after running my application. What I exactly need is the alert boxes...Simple problem to solve  Respected Sir/Madam, I am... earlier. Its working in a fantastic way. My heartiest solute to Roseindia team
Simple problem to solve - JSP-Servlet
in next page after running my application. What I exactly need is the alert boxes...Simple problem to solve  Respected Sir/Madam, I am... earlier. Its working in a fantastic way. My heartiest solute to Roseindia team
doubt in my program code - Java Beginners
doubt in my program code  i have developed a web browser... we can see as the name of all the buttons.my question is i need to change the name on that button.can u please help me out to solve this problem.if u need
need of code
need of code  howto convert greyscale image to binary image in java
WRITE A CODE IN STRUTS ACTION CLASS FOR CHECK BOXES AND RADIO BUTTONS - Struts
WRITE A CODE IN STRUTS ACTION CLASS FOR CHECK BOXES AND RADIO BUTTONS  Hello frnds, I am sending this second time help me out. i need help from u esteemed and talented people.iwould like to write code in struts action class
What's wrong with my pagination code in JSP?
What's wrong with my pagination code in JSP?  Dear experts, I've.... Hope someone can advise me how to. Thanks! print("code sample"); <...; print("code sample");   JSP Pagination The given code retrieves
query in simple code..i had described all...........
query in simple code..i had described all...........  SAME HERE IF YOU GET THIS PROBLEM SOLVED THEN PLEASE REPLY......... MY ONE JAVA FILE IS: abstract class A { abstract void callmetoo() { System.out.println("anoop
need
it???? simply i mean to say capturing the user click in my webpage anywhere
need
it???? simply i mean to say capturing the user click in my webpage anywhere
i need a java code for finding typemismatch in an editor.
i need a java code for finding typemismatch in an editor.  hi im sriram, i need a java code in such a way that typemismatch code is embedded with the simple java editor. the sample output is shown below !alt text
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

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.