Tuesday, November 10, 2015

Java Codes

Que- How to create a sells details using java codes

import java.awt.*;smpcprogram.blogspot.in
import java.awt.event.*;
public class Sales extends Frame implements ItemListener
{
Frame f;
Label l1,l2,l3,l4,l5,l6,l7,l8;
TextField t1,t2,t3,t4,t5,t6,t7;
Checkbox cb1,cb2,cb3;
CheckboxGroup cbg;
public Sales()
{
l1=new Label("Item code");
l2=new Label("Item name");
l3=new Label("Price");
l4=new Label("Quantity");
l5=new Label("Amount");
l6=new Label("Discount");
l7=new Label("Discount amount");
l8=new Label("Payable amount");

t1=new TextField(5);
t2=new TextField(15);
t3=new TextField(5);
t4=new TextField(5);
t5=new TextField(5);
t6=new TextField(5);
t7=new TextField(10);

f=new Frame("Sales report");
cbg=new CheckboxGroup();
cb1=new Checkbox("5",cbg,false);
cb2=new Checkbox("10",cbg,false);
cb3=new Checkbox("15",cbg,false);
f.setSize(600,600);
f.setVisible(true);
f.setBackground(Color.pink);

f.add(l1);
f.add(t1);
f.add(l2);
f.add(t2);
f.add(l3);
f.add(t3);
f.add(l4);
f.add(t4);
f.add(l5);
f.add(t5);
f.add(l6);
f.add(cb1);
f.add(cb2);
f.add(cb3);
f.add(l7);
f.add(t6);
f.add(l8);
f.add(t7);
f.setLayout(null);
cb1.addItemListener(this);
cb2.addItemListener(this);
cb3.addItemListener(this);
l1.setBounds(200,100,70,25);
t1.setBounds(275,100,70,25);
l2.setBounds(200,150,70,25);
t2.setBounds(275,150,70,25);
l3.setBounds(200,200,70,25);
t3.setBounds(275,200,70,25);
l4.setBounds(200,250,70,25);
t4.setBounds(275,250,70,25);
l5.setBounds(200,300,70,25);
t5.setBounds(275,300,70,25);
l6.setBounds(200,350,50,25);
cb1.setBounds(310,350,40,15);
cb2.setBounds(360,350,40,15);
cb3.setBounds(410,350,40,15);
l7.setBounds(200,380,70,25);
t6.setBounds(275,380,70,25);
l8.setBounds(200,425,50,25);
t7.setBounds(275,425,50,25);
}
public void itemStateChanged(ItemEvent ie)
{
String s1=t3.getText();
String s2=t4.getText();
int a=Integer.parseInt(s1);
int b=Integer.parseInt(s2);
int c=a*b;
String s3=String.valueOf(c);
t5.setText(s3);

if(ie.getItemSelectable()==cb1)
{
int d=c/20;
String s4=String.valueOf(d);
t6.setText(s4);
int e=c-d;
String s5=String.valueOf(e);
t7.setText(s5);
}

if(ie.getItemSelectable()==cb2)
{
int d=c/10;
String s4=String.valueOf(d);
t6.setText(s4);
int e=c-d;
String s5=String.valueOf(e);
t7.setText(s5);
}

if(ie.getItemSelectable()==cb3)
{
int d=(3*c)/20;
String s4=String.valueOf(d);
t6.setText(s4);
int e=c-d;
String s5=String.valueOf(e);
t7.setText(s5);
}
}
public static void main(String args[])
{
Sales ob=new Sales();
}
}






































1 comment:


  1. Thanks, this is generally helpful.
    Still, I followed step-by-step your method in this Java training
    Java course

    ReplyDelete