John Delmark Aguilar

Delmark - Profiling
 
HomeCalendarFAQSearchMemberlistUsergroupsRegisterLog in

Share | 
 

 Payroll Java

View previous topic View next topic Go down 
AuthorMessage
dElmARk
Admin
Admin
avatar

Posts : 92
Join date : 09/04/2012

PostSubject: Payroll Java   Sat Feb 23, 2013 4:33 pm

Code:
import java.io.*;
import java.util.*;
import javax.swing.*;
import java.awt.event.*;
public class payroll extends JFrame{
    JLabel empl = new JLabel("Employee Code: ");
    JButton ok = new JButton("ok");JButton cls = new JButton("clear");
    JTextField emp = new JTextField();
    double salrate,salary,in,out,workedHr;
    String []days={"Monday","Tuesday","Wednesday","Thursday","Friday"};
    payroll(){
          setLayout(null);
          setBounds(500,270,320,170);
          emp.setBounds(120,40,150,22);
          empl.setBounds(28,40,100,22);
          cls.setBounds(170,70,80,22);
          ok.setBounds(80,70,80,22);
          add(ok);add(cls);add(emp);add(empl);
          setDefaultCloseOperation(EXIT_ON_CLOSE);
          setVisible(true);
          cls.addActionListener(new ActionListener(){
              public void actionPerformed(ActionEvent e){
                    emp.setText("");
              }
          });
          ok.addActionListener(new ActionListener(){
              public void actionPerformed(ActionEvent e){
                    login();
              }
          });
    }
    void login(){
          try{
              Scanner sc=new Scanner(new File("emps.txt"));
              while(sc.hasNextLine()){
                    String [] inf=sc.nextLine().split(", ");
                    if(emp.getText().equals(inf[1])){
                        switch(Integer.parseInt(inf[2])){
                              case 1: salrate = 380; break;
                              case 2: salrate = 450; break;
                              case 3: salrate = 550; break;
                        }
                        JOptionPane.showMessageDialog(null,"-Employee Information-\nName: "+inf[0]+"\nCode: "+inf[1]+"\nLevel: "+inf[2]+"\nSalary Rate: "+salrate);
                        for( int i=1;i<days.length;i++){
                              tin= JOptionPane.showInputDialog(null,"Enter Time-in for "+days[i]);
                              rin=tin.split(":");
                        }
                    }
              }
          }catch(Exception ee){}
    }
    public static void main(String [] pcs){
          new payroll();
    }   
}


emps.txt
Code:

asdqwe, 001, 1
asdweq, 002, 2
qwewqa, 003, 3
Back to top Go down
View user profile http://delmark.meabout.com
 
Payroll Java
View previous topic View next topic Back to top 
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
John Delmark Aguilar :: dElmARk Productions :: Java Programs :: Tutorials-
Jump to: