heena tejwani project on java ,final year bca ,dezyne e'cole college
TRANSCRIPT
Application on Java Language
Submitted By
Heena Tejwani
BCA – 3rd Year
Dezyne E’ cole College106/10, Civil Lines, Ajmer
Tel: 0145-2624679
www.dezyneecole.com
2015-2016
2
Acknowledgement
With due Regards,
Heena Tejwani
BCA 3rd Year
3
This application on Java Language” was developed at Dezyne E’cole
College.
During the making of this project I have learnt a lot and I thank my mentor
Mr. Tarun Sharma for helping us during the making of project.
I thank my college “Dezyne E’cole College” for having conducted this
“Identity” exhibition for helping us to bring out our skill.
Salary Calculator
Interface Of Application
HEENA TEJWANI
Bachelor Of Computer
Application 3rd year
Dezyne E’cole College
www.dezyneecole.com
4
eg. Basic Salary=10000 for Manager in Urban
Salary Calculator
Eg. Basic Salary=5000 for Clerk in Rural
HEENA TEJWANI
Bachelor Of Computer
Application 3rd year
Dezyne E’cole College
www.dezyneecole.com
5
Provide Print with all Details
public Demo1()
{
f=new Frame();
f.setTitle("Salary Calculator");
f.setBackground(new Color(90,126,220));
f.setLayout(null);
f.setResizable(false);
f.setBounds(500,150,670,500);
Q=Toolkit.getDefaultToolkit();
Image img=Q.getImage(imgname);
f.setIconImage(img);
lbl1=new JLabel("Basic Salary");
lbl1.setForeground(Color.white);
lbl1.setBounds(20,30,90,20);f.add(lbl1);
lbl2=new JLabel("Designation");
lbl2.setForeground(Color.white);
lbl2.setBounds(400,30,90,20);f.add(lbl2);
lbl3=new JLabel("Status");
lbl3.setForeground(Color.white);
lbl3.setBounds(20,70,90,20);f.add(lbl3);
lbl4=new JLabel("Area");
lbl4.setForeground(Color.white);
lbl4.setBounds(400,70,90,20);f.add(lbl4);
lbl5=new JLabel("Allowance");
lbl5.setForeground(Color.white);
lbl5.setBounds(20,130,90,20);f.add(lbl5);
lbl6=new JLabel("D A");
lbl6.setForeground(Color.white);
6
Source Code-
lbl6.setBounds(20,230,90,20);f.add(lbl6);
lbl7=new JLabel("H R A");
lbl7.setForeground(Color.white);
lbl7.setBounds(20,260,90,20);f.add(lbl7);
lbl8=new JLabel("Other");
lbl8.setForeground(Color.white);
lbl8.setBounds(20,290,90,20);f.add(lbl8);
lbl9=new JLabel("Total Earnings");
lbl9.setForeground(Color.white);
lbl9.setBounds(20,320,90,20);f.add(lbl9);
lbl10=new JLabel("Income Tax");
lbl10.setForeground(Color.white);
lbl10.setBounds(370,230,90,20);f.add(lbl10);
lbl11=new JLabel("P F");
lbl11.setForeground(Color.white);
lbl11.setBounds(370,260,90,20);f.add(lbl11);
lbl12=new JLabel("Social Contribution");
lbl12.setForeground(Color.white);
lbl12.setBounds(370,290,120,20);f.add(lbl12);
lbl13=new JLabel("Total Deductions");
lbl13.setForeground(Color.white);
lbl13.setBounds(370,320,120,20);f.add(lbl13);
lbl14=new JLabel("Salary in Hand");
lbl14.setForeground(Color.white);
lbl14.setBounds(300,410,90,20);f.add(lbl14);
lbl15=new JLabel("__________________________________________________________________________________________________");
lbl15.setForeground(Color.white);
lbl15.setBounds(0,100,700,20);f.add(lbl15);
lbl16=new
7
JLabel("__________________________________________________________________________________________________");
lbl16.setForeground(Color.white);
lbl16.setBounds(0,150,700,20);f.add(lbl16);
lbl17=new JLabel("__________________________________________________________________________________________________");
lbl17.setForeground(Color.white);
lbl17.setBounds(0,390,700,20);f.add(lbl17);Font f1=new Font("Arial",Font.BOLD,13);
txt1=new JTextField();
txt1.setFont(f1);
txt1.setBackground(new Color(180,214,248));
txt1.setBounds(110,30,150,30);f.add(txt1);
txt2=new JTextField();
txt2.setFont(f1);
txt2.setBackground(new Color(180,214,248));
txt2.setBounds(110,230,150,20);f.add(txt2);
txt3=new JTextField();
txt3.setFont(f1);
txt3.setBackground(new Color(180,214,248));
txt3.setBounds(110,260,150,20);f.add(txt3);
txt4=new JTextField();
txt4.setFont(f1);
txt4.setBackground(new Color(180,214,248));
txt4.setBounds(110,290,150,20);f.add(txt4);
txt5=new JTextField();
txt5.setFont(f1);
txt5.setBackground(new Color(180,214,248));
txt5.setBounds(110,320,150,20);f.add(txt5);
txt6=new JTextField();
8
txt6.setFont(f1);
txt6.setBackground(new Color(180,214,248));
txt6.setBounds(480,230,150,20);f.add(txt6);
txt7=new JTextField();
txt7.setFont(f1);
txt7.setBackground(new Color(180,214,248));
txt7.setBounds(480,260,150,20);f.add(txt7);
txt8=new JTextField();
txt8.setFont(f1);
txt8.setBackground(new Color(180,214,248));
txt8.setBounds(480,290,150,20);f.add(txt8);
txt9=new JTextField();
txt9.setFont(f1);
txt9.setBackground(new Color(180,214,248));
txt9.setBounds(480,32
0,150,20);f.add(txt9);
txt10=new JTextField();
txt10.setFont(f1);
txt10.setBackground(new Color(180,214,248));
txt10.setBounds(240,430,200,40);f.add(txt10);
c1=new JCheckBox("Car");
c1.setForeground(Color.white);
c1.setBackground(new Color(90,126,220));
c1.setBounds(110,130,50,20);f.add(c1);
c2=new JCheckBox("Uniform");
c2.setForeground(Color.white);
c2.setBackground(new Color(90,126,220));
c2.setBounds(200,130,80,20);f.add(c2);
c3=new JCheckBox("Gym"); 9
c3.setForeground(Color.white);
c3.setBackground(new Color(90,126,220));
c3.setBounds(300,130,80,20);f.add(c3);
c4=new JCheckBox("Mobile");
c4.setForeground(Color.white);
c4.setBackground(new Color(90,126,220));
c4.setBounds(400,130,80,20);f.add(c4);
c5=new JCheckBox("Entertainment");
c5.setForeground(Color.white);
c5.setBackground(new Color(90,126,220));
c5.setBounds(500,130,130,20);f.add(c5);
b1=new JButton("Calculate Earnings");
b1.setBackground(Color.white);
b1.setBounds(50,180,250,30);f.add(b1);
b2=new JButton("Calculate Deductions");
b2.setBackground(Color.white);
b2.setBounds(380,180,250,30);f.add(b2);
b3=new JButton("Calculate Salary in Hand");
b3.setBackground(Color.white);
b3.setBounds(50,360,180,30);f.add(b3);
b4=new JButton("Reset");
b4.setBackground(Color.white);
b4.setBounds(250,360,180,30);f.add(b4);
b5=new JButton("Print");
b5.setBackground(Color.white);
b5.setBounds(450,360,180,30);f.add(b5);
b1.setEnabled(false);
b2.setEnabled(false);
b3.setEnabled(false);
b4.setEnabled(false);
10
b5.setEnabled(false);
txt2.setEditable(false);
txt3.setEditable(false);
txt4.setEditable(false);
txt5.setEditable(false);
txt6.setEditable(false);
txt7.setEditable(false);
txt8.setEditable(false);
txt9.setEditable(false);
txt10.setEditable(false);
c1.setEnabled(false);
c2.setEnabled(false);
c3.setEnabled(false);
c4.setEnabled(false);
c5.setEnabled(false);
txt1.addFocusListener(this);
rb1.addItemListener(this);
rb2.addItemListener(this);
b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
b4.addActionListener(this);
b5.addActionListener(this);
f.addWindowListener(this);
f.setVisible(true);
}
public void itemStateChanged(ItemEvent E)
{ if (E.getSource()==rb2)
{ 11
c1.setEnabled(false);
c2.setEnabled(false);
c3.setEnabled(false);
c4.setEnabled(false);
c5.setEnabled(false);
}
if (E.getSource()==rb1)
{
c1.setEnabled(true);
c2.setEnabled(true);
c3.setEnabled(true);
c4.setEnabled(true);
c5.setEnabled(true);
}
}
public void focusLost(FocusEvent e)
{
long a,k;
if(e.getSource()==txt1)
{
b1.setEnabled(true);
k=0;
for(int i=0;i<txt1.getText().length();i++)
{
a=(txt1.getText().charAt(i));
if (!(a>=48 && a<=57))
{
k=11;
} 12
}
if(k==11)
{
System.out.print(txt1.getText());
JOptionPane.showMessageDialog(null,"Enter Only Numeric Values");
}
else
{
}
double basic;
basic=Double.parseDouble(txt1.getText());
if(basic<5000)
{
JOptionPane.showMessageDialog(null,"Enter BasicSalary Above 5000");
}
}
}
public void focusGained(FocusEvent e)
{
double basic;
if(e.getSource()==txt1)
{
b4.setEnabled(true);
c1.setEnabled(true);
c2.setEnabled(true);
c3.setEnabled(true);
c4.setEnabled(true); 13
c5.setEnabled(true);
}
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==b1)
{
double basic,da=0,hra,other=0,earning;
basic=Double.parseDouble(txt1.getText());
if(rb1.isSelected())
{
if(c.getSelectedIndex()==0)
{
da=(basic*50)/100;
}
else if(c.getSelectedIndex()==1)
{
da=(basic*60)/100;
}
else if(c.getSelectedIndex()==2)
{
da=(basic*80)/100;
}
else if(c.getSelectedIndex()==3)
{
da=(basic*90)/100;
}
else
{
da=1500;14
}
}
else
{
da=1000;
}
if(rb3.isSelected())
{
hra=4000;
}
else if(rb4.isSelected())
{
hra=8000;
}
else
{
hra=0;
}
if(c1.isSelected())
{
other=3000;
}
if(c2.isSelected())
{
other=1000;
}
if(c3.isSelected())
{
other=2000;15
}
if(c4.isSelected())
{
other=1500;
}
if(c5.isSelected())
{
other=500;
}
earning=hra+da+other;
txt2.setText(Double.toString(da));
txt3.setText(Double.toString(hra));
txt4.setText(Double.toString(other));
txt5.setText(Double.toString(earning));
b2.setEnabled(true);
}
if(e.getSource()==b2)
{
double a,ba,it,pf=0,social=0,deduct;
//a=Double.parseDouble(txt2.getText());
ba=Double.parseDouble(txt1.getText());
if(rb1.isSelected())
{
if(ba>=30000)
{
it=(ba*10)/100;
}
else if(ba>=15000)
}
16
if(k==11)
{
System.out.print(txt1.getText());
JOptionPane.showMessageDialog(null,"Enter Only Numeric Values");
}
else
{
}
double basic;
basic=Double.parseDouble(txt1.getText());
if(basic<5000)
{ }
}
JOptionPane.showMessageDialog(null,"Enter Basic Salary Above 5000");
}
}
}
public void focusGained(FocusEvent e)
{
double basic;
if(e.getSource()==txt1)
{
b4.setEnabled(true);
c1.setEnabled(true);
c2.setEnabled(true);
c3.setEnabled(true);
17
c4.setEnabled(true);
c5.setEnabled(true);
}
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==b1)
{
double basic,da=0,hra,other=0,earning;
basic=Double.parseDouble(txt1.getText());
if(rb1.isSelected())
{
if(c.getSelectedIndex()==0)
{
da=(basic*50)/100;
}
else if(c.getSelectedIndex()==1)
{
da=(basic*60)/100;
}
else if(c.getSelectedIndex()==2)
{
da=(basic*80)/100;
}
else if(c.getSelectedIndex()==3)
{
da=(basic*90)/100;
}
else
{18
da=1500;
}
}
else
{
da=1000;
}
if(rb3.isSelected())
{
hra=4000;
}
else if(rb4.isSelected())
{
hra=8000;
}
else
{
hra=0;
}
if(c1.isSelected())
{
other=3000;
}
if(c2.isSelected())
{
other=1000;
}
if(c3.isSelected())
{19
other=2000;
}
if(c4.isSelected())
{
other=1500;
}
if(c5.isSelected())
{
other=500;
}
earning=hra+da+other;
txt2.setText(Double.toString(da));
txt3.setText(Double.toString(hra));
txt4.setText(Double.toString(other));
txt5.setText(Double.toString(earning));
b2.setEnabled(true);
}
if(e.getSource()==b2)
{
double a,ba,it,pf=0,social=0,deduct;
//a=Double.parseDouble(txt2.getText());
ba=Double.parseDouble(txt1.getText());
if(rb1.isSelected())
{
if(ba>=30000)
{
it=(ba*10)/100;
}
else if(ba>=15000)20
{
it=(ba*20)/100;
}
else
{
it=(ba*30)/100;
pf=(ba*30)/100;
social=2000;
}
}
else
{
it=1000;
}
deduct=it+pf+social;
txt6.setText(Double.toString(it));
txt7.setText(Double.toString(pf));
txt8.setText(Double.toString(social));
txt9.setText(Double.toString(deduct));
b3.setEnabled(true);
}
if(e.getSource()==b3)
{
double bh,eh,dh,sh;
bh=Double.parseDouble(txt1.getText());
eh=Double.parseDouble(txt5.getText());
dh=Double.parseDouble(txt9.getText());
sh=bh+eh-dh;
txt10.setText(Double.toString(sh));
b5.setEnabled(true);21
{
if(e.getSource()==b4)
{
txt1.setText("");
txt2.setText("");
txt3.setText("");
txt4.setText("");
txt5.setText("");
txt6.setText("");
txt7.setText("");
txt8.setText("");
txt9.setText("");
txt10.setText("");
rb1=new JRadioButton("Permanent",false);
g.add(rb1);
rb3=new JRadioButton("Rural",false);
g1.add(rb3);
c1.setSelected(false);
c2.setSelected(false);
c3.setSelected(false);
c4.setSelected(false);
c5.setSelected(false);
rb1.setSelected(true);
rb3.setSelected(true);
b1.setEnabled(false);
b2.setEnabled(false);
b3.setEnabled(false);
b4.setEnabled(false);22
b5.setEnabled(false);
c1.setEnabled(false);
c2.setEnabled(false);
c3.setEnabled(false);
c4.setEnabled(false);
c5.setEnabled(false);
}
if(e.getSource()==b5)
{
double s1,s2,s3,s4,s5,s6;
String l,l1,co1;
s1=Double.parseDouble(txt1.getText());
s2=Double.parseDouble(txt2.getText());
s3=Double.parseDouble(txt3.getText());
s4=Double.parseDouble(txt6.getText());
s5=Double.parseDouble(txt7.getText());
s6=Double.parseDouble(txt10.getText());
JOptionPane.showMessageDialog(null,"Your Slip is Prepared");
if(rb1.isSelected())
{
l=rb1.getLabel();
}
else
{
l=rb2.getLabel();
}
if(rb3.isSelected())
{
l1=rb3.getLabel();
23
}
else
{
l1=rb4.getLabel();
}
co1=(String)c.getSelectedItem();
try
{
ByteArrayOutputStream obj=new ByteArrayOutputStream();
String s="\tState Bank of India\n\n"+"BasicSalary\t\t"+s1+"\nDesignation\t\t"+co1+"\nStatus\t\t\t"+l+"\nArea\t\t\t\t"+l1+
"\nDA\t\t\t\t"+s2+"\nHRA\t\t\t\t"+s3+"\nIncomeTax\t\t"+s4+"\nPF\t\t\t\t"+s5+"\nSalary in Hand\t"+s6;
byte b[]=s.getBytes();
obj.write(b);
byte b1[]=obj.toByteArray();
OutputStream os=new FileOutputStream("Output.doc");
obj.writeTo(os);
obj.close();
obj.reset();
}
catch(Exception f)
{
System.out.println(f);
}
24