Solved

Calculation payroll

Posted on 2003-10-22
10
595 Views
Last Modified: 2010-03-31
This program is supposed to calculate payroll. Been struggnling around for hours
There is a problem with the calculation fonction. It returns 0 like the calculation isn't working. Any help would be appreciated.

Here are the requirements:

The program requirements are:

·        Is well labeled.

·        Is documented.

·        Is tested.

·        Has an input field for the date, which is automatically filled but can be overwritten.

·        Has an input field for a social security number.  The social security number is checked against 5 valid values and then brings up the name of the employee or an error message.

·        Allows for 6 in and out times within the day (6 pairs of input fields).  In other words, the employee can check in and out 6 times.

·        Has an input field for hours of sick leave taken that day (2 decimal positions).

·        Has an input field for hours of personal leave taken that day (2 decimal positions).

·        Does not allow the employee to have more than 8 hours of actual working hours if sick leave or personal leave is taken that day.

 

·        After entering data, the hours worked that day are displayed.

·        After entering data, the pay for that day is displayed.  Pay rate is $10.00/hour.  Time and a half is paid for overtime (more than 8 hours).

·        Cannot be crashed.



Also it needs to allow to enter the employee name.
Thank you, Here is the code:

_________________________________________________________________________

import java.lang.Double;
import java.util.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

/*
 * Hours.java
 *
 * Created on October 12, 2003, 4:51 PM
 * Modified October 19, 2003
 *       Added variables and getter for sick and personal Action Performed
 *       (Sick time and Personal Time)
 */

/**
 *
 * @author  David Offutt
 * Modified 10/19/03 by Linda Brooks
 * Modified 10/20/03 by Jim Niemeyer
 * Modified 10/22/03 by Stephanie De Bernardi
 */
public class Hours4a extends javax.swing.JApplet {
            String stime;
          double inputStime;
          String ptime;
          double inputPtime;
          double hours;
          double totalPay;
          double payRate = 10.00;





    /** Initializes the applet Hours */
    public void init() {
        initComponents();
    }

    /** This method is called from within the init() method to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    private void initComponents() {//GEN-BEGIN:initComponents
        java.awt.GridBagConstraints gridBagConstraints;

        timeIn1 = new javax.swing.JTextField();
        timeIn2 = new javax.swing.JTextField();
        timeIn3 = new javax.swing.JTextField();
        timeIn4 = new javax.swing.JTextField();
        timeIn5 = new javax.swing.JTextField();
        timeIn6 = new javax.swing.JTextField();
        timeOut1 = new javax.swing.JTextField();
        timeOut2 = new javax.swing.JTextField();
        timeOut3 = new javax.swing.JTextField();
        timeOut4 = new javax.swing.JTextField();
        timeOut5 = new javax.swing.JTextField();
        timeOut6 = new javax.swing.JTextField();
        inTime1 = new javax.swing.JLabel();
        inTime2 = new javax.swing.JLabel();
        inTime3 = new javax.swing.JLabel();
        inTime4 = new javax.swing.JLabel();
        inTime5 = new javax.swing.JLabel();
        inTime6 = new javax.swing.JLabel();
        outTime1 = new javax.swing.JLabel();
        outTime2 = new javax.swing.JLabel();
        outTime3 = new javax.swing.JLabel();
        outTime4 = new javax.swing.JLabel();
        outTime5 = new javax.swing.JLabel();
        outTime6 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        dateYes = new javax.swing.JButton();
        dateCanx = new javax.swing.JButton();
        jTextField1 = new javax.swing.JTextField();
        jLabel14 = new javax.swing.JLabel();
        Date = new javax.swing.JLabel();
        jSeparator1 = new javax.swing.JSeparator();
        jSeparator2 = new javax.swing.JSeparator();
        jSeparator3 = new javax.swing.JSeparator();
        jSeparator4 = new javax.swing.JSeparator();
        jSeparator5 = new javax.swing.JSeparator();
        jSeparator6 = new javax.swing.JSeparator();
        jSeparator7 = new javax.swing.JSeparator();
        jSeparator8 = new javax.swing.JSeparator();
        jSeparator9 = new javax.swing.JSeparator();
        jSeparator10 = new javax.swing.JSeparator();
        jSeparator11 = new javax.swing.JSeparator();
        jSeparator12 = new javax.swing.JSeparator();
        jSeparator13 = new javax.swing.JSeparator();
        jSeparator14 = new javax.swing.JSeparator();
        jSeparator16 = new javax.swing.JSeparator();
        sick = new javax.swing.JLabel();
        personal = new javax.swing.JLabel();
        payLabel = new javax.swing.JLabel();
        sickTime = new javax.swing.JTextField();
        personalTime = new javax.swing.JTextField();
        pay = new javax.swing.JTextField();
        calculate = new javax.swing.JButton();
        jLabel19 = new javax.swing.JLabel();
        jSeparator15 = new javax.swing.JSeparator();
        jSeparator17 = new javax.swing.JSeparator();
        jSeparator18 = new javax.swing.JSeparator();

//              This section populates the drop-down item selections
        ssnSelect = new javax.swing.JComboBox();
                          ssnSelect.addItem("010221254");
                          ssnSelect.addItem("100853746");
                          ssnSelect.addItem("254374556");
                          ssnSelect.addItem("323543574");
                          ssnSelect.addItem("456376453");
                          ssnSelect.addItem("543653847"); // end SSN dropdown list


        getContentPane().setLayout(new java.awt.GridBagLayout());

        setName("Payroll Calculator");
        timeIn1.setToolTipText("Time In 1; Enter in 24 hour format");
        timeIn1.setMinimumSize(new java.awt.Dimension(55, 20));
        timeIn1.setPreferredSize(new java.awt.Dimension(55, 20));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 14;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        getContentPane().add(timeIn1, gridBagConstraints);

        timeIn2.setToolTipText("Time In 2; Enter in 24 hour format");
        timeIn2.setMinimumSize(new java.awt.Dimension(55, 20));
        timeIn2.setPreferredSize(new java.awt.Dimension(55, 20));
        timeIn2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                timeIn2ActionPerformed(evt);
            }
        });

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 15;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        getContentPane().add(timeIn2, gridBagConstraints);

        timeIn3.setToolTipText("Time In 3; Enter in 24 hour format");
        timeIn3.setMinimumSize(new java.awt.Dimension(55, 20));
        timeIn3.setPreferredSize(new java.awt.Dimension(55, 20));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 16;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        getContentPane().add(timeIn3, gridBagConstraints);

        timeIn4.setToolTipText("Time In 4; Enter in 24 hour format");
        timeIn4.setMinimumSize(new java.awt.Dimension(55, 20));
        timeIn4.setPreferredSize(new java.awt.Dimension(55, 20));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 18;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        getContentPane().add(timeIn4, gridBagConstraints);

        timeIn5.setToolTipText("Time In 5; Enter in 24 hour format");
        timeIn5.setMinimumSize(new java.awt.Dimension(55, 20));
        timeIn5.setPreferredSize(new java.awt.Dimension(55, 20));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 20;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        getContentPane().add(timeIn5, gridBagConstraints);

        timeIn6.setToolTipText("Time In 6; Enter in 24 hour format");
        timeIn6.setMinimumSize(new java.awt.Dimension(55, 20));
        timeIn6.setPreferredSize(new java.awt.Dimension(55, 20));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 22;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        getContentPane().add(timeIn6, gridBagConstraints);

        timeOut1.setToolTipText("Time Out 1; Enter in 24 hour format");
        timeOut1.setMinimumSize(new java.awt.Dimension(55, 20));
        timeOut1.setPreferredSize(new java.awt.Dimension(55, 20));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 6;
        gridBagConstraints.gridy = 14;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        getContentPane().add(timeOut1, gridBagConstraints);

        timeOut2.setToolTipText("Time Out 2; Enter in 24 hour format");
        timeOut2.setMinimumSize(new java.awt.Dimension(55, 20));
        timeOut2.setPreferredSize(new java.awt.Dimension(55, 20));
        timeOut2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                timeOut2ActionPerformed(evt);
            }
        });

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 6;
        gridBagConstraints.gridy = 15;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHEAST;
        getContentPane().add(timeOut2, gridBagConstraints);

        timeOut3.setToolTipText("Time Out 3; Enter in 24 hour format");
        timeOut3.setMinimumSize(new java.awt.Dimension(55, 20));
        timeOut3.setPreferredSize(new java.awt.Dimension(55, 20));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 6;
        gridBagConstraints.gridy = 16;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHEAST;
        getContentPane().add(timeOut3, gridBagConstraints);

        timeOut4.setToolTipText("Time Out 4; Enter in 24 hour format");
        timeOut4.setMinimumSize(new java.awt.Dimension(55, 20));
        timeOut4.setPreferredSize(new java.awt.Dimension(55, 20));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 6;
        gridBagConstraints.gridy = 18;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHEAST;
        getContentPane().add(timeOut4, gridBagConstraints);

        timeOut5.setToolTipText("Time Out 5; Enter in 24 hour format");
        timeOut5.setMinimumSize(new java.awt.Dimension(55, 20));
        timeOut5.setPreferredSize(new java.awt.Dimension(55, 20));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 6;
        gridBagConstraints.gridy = 20;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHEAST;
        getContentPane().add(timeOut5, gridBagConstraints);

        timeOut6.setToolTipText("Time Out 6; Enter in 24 hour format");
        timeOut6.setMinimumSize(new java.awt.Dimension(55, 20));
        timeOut6.setPreferredSize(new java.awt.Dimension(55, 20));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 6;
        gridBagConstraints.gridy = 22;
        getContentPane().add(timeOut6, gridBagConstraints);

        inTime1.setText("Time In 1");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 14;
        getContentPane().add(inTime1, gridBagConstraints);

        inTime2.setText("Time In 2");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 15;
        getContentPane().add(inTime2, gridBagConstraints);

        inTime3.setText("Time In 3");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 16;
        getContentPane().add(inTime3, gridBagConstraints);

        inTime4.setText("Time In 4");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 18;
        getContentPane().add(inTime4, gridBagConstraints);

        inTime5.setText("Time In 5");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 20;
        getContentPane().add(inTime5, gridBagConstraints);

        inTime6.setText("Time In 6");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 22;
        getContentPane().add(inTime6, gridBagConstraints);

        outTime1.setText("Time Out 1");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 5;
        gridBagConstraints.gridy = 14;
        getContentPane().add(outTime1, gridBagConstraints);

        outTime2.setText("Time Out 2");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 5;
        gridBagConstraints.gridy = 15;
        getContentPane().add(outTime2, gridBagConstraints);

        outTime3.setText("Time Out 3");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 5;
        gridBagConstraints.gridy = 16;
        getContentPane().add(outTime3, gridBagConstraints);

        outTime4.setText("Time Out 4");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 5;
        gridBagConstraints.gridy = 18;
        getContentPane().add(outTime4, gridBagConstraints);

        outTime5.setText("Time Out 5");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 5;
        gridBagConstraints.gridy = 20;
        getContentPane().add(outTime5, gridBagConstraints);

        outTime6.setText("Time Out 6");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 5;
        gridBagConstraints.gridy = 22;
        getContentPane().add(outTime6, gridBagConstraints);

        jLabel13.setText("Time Entry");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 3;
        gridBagConstraints.gridy = 15;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTH;
        getContentPane().add(jLabel13, gridBagConstraints);

        dateYes.setText("Accept Date");
        dateYes.setToolTipText("Accept Date");
        dateYes.setPreferredSize(new java.awt.Dimension(125, 26));
        dateYes.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                dateYesActionPerformed(evt);
            }
        });

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 3;
        gridBagConstraints.gridy = 9;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
        getContentPane().add(dateYes, gridBagConstraints);

        dateCanx.setText("Enter Own Date");
        dateCanx.setToolTipText("Cancels Date Entry");
        dateCanx.setMaximumSize(new java.awt.Dimension(60, 26));
        dateCanx.setMinimumSize(new java.awt.Dimension(60, 26));
        dateCanx.setPreferredSize(new java.awt.Dimension(125, 26));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 4;
        gridBagConstraints.gridy = 9;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
        getContentPane().add(dateCanx, gridBagConstraints);

        jTextField1.setMinimumSize(new java.awt.Dimension(10, 30));
        jTextField1.setPreferredSize(new java.awt.Dimension(50, 20));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 4;
        gridBagConstraints.gridy = 8;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTH;
        getContentPane().add(jTextField1, gridBagConstraints);

// This section determines the current date and places the value in the Date box
              GregorianCalendar currentCalendar = new GregorianCalendar();

           int currentMonth = currentCalendar.get(currentCalendar.MONTH);
               int currentDay = currentCalendar.get(currentCalendar.DAY_OF_MONTH);
              int currentYear = currentCalendar.get(currentCalendar.YEAR);
               String currentDate = ((currentMonth+1)+"/"+currentDay+"/"+currentYear);
              jTextField1.setText(currentDate); // end automatic current date section

// This section clears out the date if the user selects "Enter Own Date" button
              dateCanx.addActionListener(new ActionListener()
              {
              public void actionPerformed(ActionEvent e)
              {
                          Object source = e.getSource();
                        if(source == dateCanx)
                        {
                              jTextField1.setText(null);
                        }
              }
              }
              );// end ActionListener (Enter Own Date)

        jLabel14.setText("Social Security Number");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 5;
        getContentPane().add(jLabel14, gridBagConstraints);

        Date.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        Date.setText("Date");
        Date.setMaximumSize(new java.awt.Dimension(20, 16));
        Date.setMinimumSize(new java.awt.Dimension(20, 16));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 3;
        gridBagConstraints.gridy = 8;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        getContentPane().add(Date, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 3;
        gridBagConstraints.gridy = 7;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        getContentPane().add(jSeparator1, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 7;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        getContentPane().add(jSeparator2, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 6;
        gridBagConstraints.gridy = 7;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        getContentPane().add(jSeparator3, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 4;
        gridBagConstraints.gridy = 7;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        getContentPane().add(jSeparator4, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 11;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        getContentPane().add(jSeparator5, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 5;
        gridBagConstraints.gridy = 7;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        getContentPane().add(jSeparator6, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 3;
        gridBagConstraints.gridy = 11;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        getContentPane().add(jSeparator7, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 4;
        gridBagConstraints.gridy = 11;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        getContentPane().add(jSeparator8, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 5;
        gridBagConstraints.gridy = 11;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        getContentPane().add(jSeparator9, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 6;
        gridBagConstraints.gridy = 11;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        getContentPane().add(jSeparator10, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 23;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        getContentPane().add(jSeparator11, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 3;
        gridBagConstraints.gridy = 23;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        getContentPane().add(jSeparator12, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 4;
        gridBagConstraints.gridy = 23;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        getContentPane().add(jSeparator13, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 6;
        gridBagConstraints.gridy = 23;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        getContentPane().add(jSeparator14, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 5;
        gridBagConstraints.gridy = 23;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        getContentPane().add(jSeparator16, gridBagConstraints);

        sick.setText("Sick Time");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 24;
        getContentPane().add(sick, gridBagConstraints);

        personal.setText("Personal Time");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 25;
        getContentPane().add(personal, gridBagConstraints);

        payLabel.setText("Pay");
        payLabel.setPreferredSize(new java.awt.Dimension(30, 16));
        payLabel.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 26;
        getContentPane().add(payLabel, gridBagConstraints);

        sickTime.setToolTipText("Enter # ofSick hours ");
        sickTime.setMinimumSize(new java.awt.Dimension(65, 20));
        sickTime.setPreferredSize(new java.awt.Dimension(55, 20));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 24;
        getContentPane().add(sickTime, gridBagConstraints);

        personalTime.setToolTipText("Enter # of personal time hours");
        personalTime.setMinimumSize(new java.awt.Dimension(65, 20));
        personalTime.setPreferredSize(new java.awt.Dimension(55, 20));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 25;
        getContentPane().add(personalTime, gridBagConstraints);

        pay.setMinimumSize(new java.awt.Dimension(65, 20));
        pay.setPreferredSize(new java.awt.Dimension(55, 20));
        pay.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                payActionPerformed(evt);
            }
        });
        // pay.setText(totalPay);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 26;
        getContentPane().add(pay, gridBagConstraints);

        calculate.setText("Calculate");
        calculate.setMaximumSize(new java.awt.Dimension(65, 20));
        calculate.setMinimumSize(new java.awt.Dimension(65, 20));
        calculate.setPreferredSize(new java.awt.Dimension(90, 20));
        calculate.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Click(evt);
            }
        });

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 4;
        gridBagConstraints.gridy = 25;
        getContentPane().add(calculate, gridBagConstraints);

        jLabel19.setText("Payroll Calculator");
        jLabel19.setVerticalAlignment(javax.swing.SwingConstants.TOP);
        jLabel19.setName("Payroll Calculator");
        jLabel19.setVerticalTextPosition(javax.swing.SwingConstants.TOP);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 4;
        gridBagConstraints.gridy = 0;
        getContentPane().add(jLabel19, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 7;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        getContentPane().add(jSeparator15, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 11;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        getContentPane().add(jSeparator17, gridBagConstraints);

        jSeparator18.setMinimumSize(new java.awt.Dimension(20, 20));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 23;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        getContentPane().add(jSeparator18, gridBagConstraints);

        ssnSelect.setMaximumRowCount(5);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 3;
        gridBagConstraints.gridy = 5;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        getContentPane().add(ssnSelect, gridBagConstraints);

    }//GEN-END:initComponents


       private void dateYesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_dateYesActionPerformed
        // Add your handling code here:
    }//GEN-LAST:event_dateYesActionPerformed

    private void payActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_payActionPerformed
        // Add your handling code here:
    }//GEN-LAST:event_payActionPerformed

    private void Click(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Click
        // Add your handling code here:
        // if hours > 8 then totalPay = (8*10) + ((totalHours-8)*15)

        totalPay = (hours + inputStime + inputPtime) * payRate;
        System.out.println("Total Pay: " + totalPay);

    }//GEN-LAST:event_Click

    private void timeOut2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_timeOut2ActionPerformed
        // Add your handling code here:
    }//GEN-LAST:event_timeOut2ActionPerformed

    private void sicktimeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sickTimeActionPerformed
        // Add your handling code here:
        // Handling code for Sick Time
        stime = sickTime.getText();
        inputStime = Double.parseDouble(stime);

    }//GEN-LAST:event_JTextField3ActionPerformed

    private void personalTimeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_personalTimeActionPerformed
        // Add your handling code here:
        // Handling code for Personal Time
       ptime = personalTime.getText();
        inputPtime = Double.parseDouble(ptime);
    }//GEN-LAST:event_JTextField4ActionPerformed

    private void timeIn2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_timeIn2ActionPerformed
        // Add your handling code here:
    String input1;
    String input2;
    String input3;
    String input4;
    String input5;
    String input6;
    String out1;
    String out2;
    String out3;
    String out4;
    String out5;
    String out6;
    double start1;
    double start2;
    double start3;
    double start4;
    double start5;
    double start6;
    double end1;
    double end2;
    double end3;
    double end4;
    double end5;
    double end6;
    input1 = timeIn1.getText();
    start1 = Double.parseDouble(input1);
    out1 = timeOut1.getText();
    end1 = Double.parseDouble(out1);
    input2 = timeIn2.getText();
    start2 = Double.parseDouble(input2);
    out2 = timeOut2.getText();
    end2 = Double.parseDouble(out2);
    input3 = timeIn3.getText();
    start3 = Double.parseDouble(input3);
    out3 = timeOut3.getText();
    end3 = Double.parseDouble(out3);
    input4 = timeIn4.getText();
    start4 = Double.parseDouble(input2);
    out4 = timeOut4.getText();
    end4 = Double.parseDouble(out4);
    input5 = timeIn5.getText();
    start5 = Double.parseDouble(input5);
    out5 = timeOut5.getText();;
    end5 = Double.parseDouble(out5);
    input6 = timeIn6.getText();;
    start6 = Double.parseDouble(input6);
    out6 = timeOut6.getText();;
    end6 = Double.parseDouble(out6);
    double time1 = (end1 - start1)/100;
    double time2 = (end2 - start2)/100;
    double time3 = (end3 - start3)/100;
    double time4 = (end4 - start4)/100;
    double time5 = (end5 - start5)/100;
    double time6 = (end6 - start6)/100;
    hours = (time1 + time2 + time3 + time4 + time5 + time6);
    jLabel19.setText("Payroll Calculator");

    }//GEN-LAST:event_timeIn2ActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel Date;
    private javax.swing.JButton calculate;
    private javax.swing.JButton dateCanx;
    private javax.swing.JButton dateNo;
    private javax.swing.JButton dateYes;
    private javax.swing.JLabel inTime1;
    private javax.swing.JLabel inTime2;
    private javax.swing.JLabel inTime3;
    private javax.swing.JLabel inTime4;
    private javax.swing.JLabel inTime5;
    private javax.swing.JLabel inTime6;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator10;
    private javax.swing.JSeparator jSeparator11;
    private javax.swing.JSeparator jSeparator12;
    private javax.swing.JSeparator jSeparator13;
    private javax.swing.JSeparator jSeparator14;
    private javax.swing.JSeparator jSeparator15;
    private javax.swing.JSeparator jSeparator16;
    private javax.swing.JSeparator jSeparator17;
    private javax.swing.JSeparator jSeparator18;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JSeparator jSeparator3;
    private javax.swing.JSeparator jSeparator4;
    private javax.swing.JSeparator jSeparator5;
    private javax.swing.JSeparator jSeparator6;
    private javax.swing.JSeparator jSeparator7;
    private javax.swing.JSeparator jSeparator8;
    private javax.swing.JSeparator jSeparator9;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JLabel outTime1;
    private javax.swing.JLabel outTime2;
    private javax.swing.JLabel outTime3;
    private javax.swing.JLabel outTime4;
    private javax.swing.JLabel outTime5;
    private javax.swing.JLabel outTime6;
    private javax.swing.JTextField pay;
    private javax.swing.JLabel payLabel;
    private javax.swing.JLabel personal;
    private javax.swing.JTextField personalTime;
    private javax.swing.JLabel sick;
    private javax.swing.JTextField sickTime;
    private javax.swing.JComboBox ssnSelect;
    private javax.swing.JTextField timeIn1;
    private javax.swing.JTextField timeIn2;
    private javax.swing.JTextField timeIn3;
    private javax.swing.JTextField timeIn4;
    private javax.swing.JTextField timeIn5;
    private javax.swing.JTextField timeIn6;
    private javax.swing.JTextField timeOut1;
    private javax.swing.JTextField timeOut2;
    private javax.swing.JTextField timeOut3;
    private javax.swing.JTextField timeOut4;
    private javax.swing.JTextField timeOut5;
    private javax.swing.JTextField timeOut6;
    // End of variables declaration//GEN-END:variables

}
0
Comment
Question by:stdebernardi
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 9

Expert Comment

by:yongsing
ID: 9604458
You expect us to do your homework for you? Did you read the member agreement of Experts Exchange?
0
 
LVL 15

Expert Comment

by:Javatm
ID: 9604502
I've created a payroll system before for my university way back when I was 4th year in college.
If you want too, I could sent you an e-mail of it, so that it can help you.

It is an " application to database " type payroll system but not a JApplet it uses JFrame.
It's actually a complete software with an installer & splash screen.
The database server was Microsoft Access.

Anyways I could sent it to you if you want 2 ?

0
 

Author Comment

by:stdebernardi
ID: 9604554
Yongsing,

Are you kidding ? Do you so know how many hours we worked on this code ? We've been banging our heads over it. Have you seen the codes ? Who do you think wrote it ? WE are the one who wrote the codes from scratch according to the program requirements mentioned above

The only thing I was asking is "what did we do wrong that our program doesn't calculate right"
And a hint on how to include the employees names.
I didn't ask you to do our homework for us, it's already done.
I can't believe you even say that after all the time we spent on this code.
0
 

Author Comment

by:stdebernardi
ID: 9604565
Javatm,

That would be nice and maybe it would help us to figure out what we did wrong in our code.
Thank you.
0
 
LVL 7

Accepted Solution

by:
tomboshell earned 300 total points
ID: 9605601
Ok, you just about got it.  You simply need to obtain the values when the button is clicked and then calculate.  You are not obtaining the values in your Click method, you are simply refering to class-wide variables that are set at initallization. Or that is what my quick look-through says.

the method is:
private void Click(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Click
        // Add your handling code here:
        // if hours > 8 then totalPay = (8*10) + ((totalHours-8)*15)
YOU NEED TO OBTAIN THE VALUES FROM THE TEXT FIELDS HERE. GET THE ACTUAL VALUES. IT DOES WORK, BUT IT IS ONLY WORKING WITH 0 VALUES.
        totalPay = (hours + inputStime + inputPtime) * payRate;
        System.out.println("Total Pay: " + totalPay);

    }//GEN-LAST:event_Click
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 15

Assisted Solution

by:Javatm
Javatm earned 200 total points
ID: 9609927
The way you encoded the program is somewhat hard coded kinda different from the format
that I'm used 2 and also you did not break it down into pcs. Anways give me your e-mail.

Here is a sample of one of my .java programs included for my payroll.
http://www.experts-exchange.com/Programming/Programming_Languages/Java/Q_20492543.html

Just a simple hint of a real payroll,
hope it helps . . .
JAVATM
0
 
LVL 15

Expert Comment

by:Javatm
ID: 9609945
Look at the codes above because it is where a I did my own calculations
of the salary of an employee.
0
 

Author Comment

by:stdebernardi
ID: 9620257
Javatm & Tomboshell,

Thank you very much for your help.
Our paper has been submitted.
I wish I had some more time to spend on this program to actually be able to "make it work". However, even if it has been submitted, I will keep trying until I have it right.

Javatm, if you want to send me your example that's great, maybe something will pop up as I see your example. My email address is : debernardi@sbcglobal.net  Thank you.

Thanks again to you 2 for your help and efforts.
0
 
LVL 7

Expert Comment

by:tomboshell
ID: 9622206
You welcome :)
0
 
LVL 15

Expert Comment

by:Javatm
ID: 9629932
:) Always happy to help somebody like you.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
word0 challenge 3 58
create a gui in perl 3 46
JDeveloper 12c for 32 bit 4 36
VB Script to add site to Java Exception List 4 18
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now