RECIPE & MUSIC COLLECTION , KAVITA

Monday, July 30, 2007

calculator

//=======================================================
// file calculator2.java// display lable textfield and button
//======================================================
import java.applet.*;import java.awt.*;import java.awt.event.*;
//
//=======================================================
public class calculator2 extends Applet implements ActionListener{ Button bb[ ] =new Button[10]; Button sum,sub,mul,div,c,z; Button on,off,backspace; TextField t1; Label L1; int pre_no=0; int current_no=0; int n2=0; int n3=0; int pre_flag=0; int current_flag=0; int flag=0; int i; int check;
//===============initialization of objects=======================
public void init() { L1 =new Label("CALULATOR"); add(L1); t1=new TextField(22); add(t1); on=new Button("ON"); add(on); on.addActionListener(this); off=new Button("OFF"); add(off); off.addActionListener(this); backspace=new Button("backspace"); add(backspace); backspace.addActionListener(this); c=new Button("c"); add(c); c.addActionListener(this);
for(i=0;i<10;i++) { bb[i] =new Button(String.valueOf(i)); add(bb[i]); bb[i].addActionListener(this); }
sum =new Button("+"); add (sum); sum.addActionListener(this);
sub =new Button("-"); add (sub); sub.addActionListener(this); mul =new Button("*"); add (mul); mul.addActionListener(this); div =new Button("%"); add (div); div.addActionListener(this); z=new Button("="); add(z); z.addActionListener(this); setBackground(Color.red); } public int number(int number,int k) { number=number*10+k; t1.setText(String.valueOf(number)); check=k; if(current_flag==5) { pre_flag=0; current_flag=0; pre_no=0; current_no=0;current_no=0; } return(number); }
//=======================calling the interface========================
public void actionPerformed(ActionEvent e) { flag=0; if(e.getSource()==bb[0]) n2=number(n2,0); if(e.getSource()==bb[1]) n2=number(n2,1); if(e.getSource()==bb[2]) n2=number(n2,2); if(e.getSource()==bb[3]) n2=number(n2,3); if(e.getSource()==bb[4]) n2=number(n2,4); if(e.getSource()==bb[5]) n2=number(n2,5); if(e.getSource()==bb[6]) n2=number(n2,6); if(e.getSource()==bb[7]) n2=number(n2,7); if(e.getSource()==bb[8]) n2=number(n2,8); if(e.getSource()==bb[9]) n2=number(n2,9); if(e.getSource()==mul) { t1.setText(" "); flag=1; } if(e.getSource()==div) { t1.setText(" "); flag=2; } if(e.getSource()==sum) { t1.setText(" "); flag=3; } if(e.getSource()==sub) { t1.setText(" "); flag=4; } if(e.getSource()==z) { t1.setText(" "); flag=5; } if(e.getSource()==c) { t1.setText(" "); n2=0; if(current_flag==5) { pre_flag=0; current_flag=0; pre_no=0; current_no=0; } } if(e.getSource()==backspace) { n2=(n2-check)/10; t1.setText(String.valueOf(n2)); } if(flag!=0) { pre_flag=current_flag; current_flag=flag; pre_no=current_no; current_no=n2; n2=0;flag=0; if(current_flag ==5 && pre_flag==5) { pre_flag=0; current_flag=0; pre_no=0; current_no=0; } switch(pre_flag) { case 1: current_no=pre_no * current_no ; t1.setText(String.valueOf(current_no)); break; case 2: current_no=pre_no/current_no; t1.setText(String.valueOf(current_no)); break; case 3: current_no=pre_no+current_no; t1.setText(String.valueOf(current_no)); break; case 4: current_no=pre_no-current_no; t1.setText(String.valueOf(current_no)); break; case 5: current_no=pre_no; t1.setText(String.valueOf(current_no)); } } } }

su du ku

//=======================================================
// file SU_DU_KU.java//

//======================================================
import java.applet.*;import java.awt.*;import java.awt.event.*;
////=======================================================
public class SU_DU_KU extends Applet implements ActionListener

{
Button START,NEXT;
TextField t[] =new TextField[81];
int a[][] =new int[9][9];
int b[][] =new int[9][9];
Font f=new Font("helvetica",Font.BOLD,30);
//===============initialization of objects=======================
public void init()
{
int i;
Graphics g =new Graphics();
START=new Button(" CLICK START ");
add(START); START.addActionListener(this);
for(i=0;i<81;i++)>
{ t[i] =new TextField(1); add(t[i]); }
setBackground(new Color(78,50,100));
//default setting
g.setColor(Color.red);
for(i=0;i<81;i++)>
NEXT=new Button(" CLICK NEXT for NEW SUDUKU");
add(NEXT); NEXT.addActionListener(this); }
//===================================================================
public void paint(Graphics g)
{ g.setColor(new Color(8,8,9)); g.fillRect(0,26,350,254); g.setColor(Color.red); g.fillRect(0,26,350,6); g.fillRect(0,112,350,6); g.fillRect(0,196,350,6); g.fillRect(0,280,350,6); g.fillRect(0,26,6,254); g.fillRect(108,26,6,254); g.fillRect(216,26,6,254); g.fillRect(324,26,6,254); g.setFont(f); }
//=======================calling the interface========================
public void actionPerformed(ActionEvent e) { int i,j,k=0; if(e.getSource()==START)
{
//reading text from text field and assign to
b[i][j] for(i=0;i<9;i++) j="0;j<9;j++)" k="0;" i="0;i<9;i++)" j="0;j<9;j++)" i="0;i<81;i++)">
//==========================================================================
//===========================call_sudu_ku( )=================================
public void call_sudu_ku( ) { int i,j,k,l; int m[]=new int[90]; int n[]=new int[90]; int count=0; int temp1,temp2; int p=0; for(i=0;i<9;i++) j="0;j<9;j++)" temp1="compare(i,j)" temp1="=" p="p+1;" temp2="0;" temp2="1;" p="p-2;" i="m[p];" j="n[p];" temp2="=" count="=">
//=======================compare(int i,int j)==================================
public int compare(int i,int j) { int k,l,temp; temp=1;
// checking for horizontal
for(k=0;k<9;k++) temp="0;" k="0;k<9;k++)" temp="0;" k="0;k<3;k++)" l="0;l<3;l++)" i="=" j="=" temp="0;">2) { for(k=0;k<3;k++) l="3;l<6;l++)" i="=" j="=" temp="0;">5) { for(k=0;k<3;k++) l="6;l<9;l++)" i="=" j="=" temp="0;">2 &&amp;i<6 k="3;k<6;k++)" l="0;l<3;l++)" i="=" j="=" temp="0;">2&& i<6>2) { for(k=3;k<6;k++) l="3;l<6;l++)" i="=" j="=" temp="0;">2 && i<6>5) { for(k=3;k<6;k++) l="6;l<9;l++)" i="=" j="=" temp="0;">5&&j<3) k="6;k<9;k++)" l="0;l<3;l++)" i="=" j="=" temp="0;">5 && j<6&&j>2) { for(k=6;k<9;k++) l="3;l<6;l++)" i="=" j="=" temp="0;">5 &&j>5) { for(k=6;k<9;k++) l="6;l<9;l++)" i="=" j="=" temp="0;">

sudoku program

//=======================================================// file button1.java// display lable textfield and button//======================================================import java.applet.*;import java.awt.*;import java.awt.event.*;////=======================================================
public class calculator2 extends Applet implements ActionListener{ Button bb[ ] =new Button[10]; Button sum,sub,mul,div,c,z; TextArea t1; Label L1; int n1=0; int n2=0; int n3=0; int flag1=0; int flag2=0; int flag=0; int i; //===============initialization of objects======================= public void init() { L1 =new Label(" CALULATOR "); add(L1); t1=new TextField(10); add(t1); for(i=0;i<10;i++) { bb[i] =new Button(String.valueOf(i)); add(bb[i]); bb[i].addActionListener(this); }
sum =new Button("+"); add (sum); sum.addActionListener(this);
sub =new Button("-"); add (sub); sub.addActionListener(this); mul =new Button("*"); add (mul); mul.addActionListener(this); div =new Button("%"); add (div); div.addActionListener(this); c=new Button("c"); add(c); c.addActionListener(this); z=new Button("="); add(z); z.addActionListener(this); } //=======================calling the interface======================== public void actionPerformed(ActionEvent e) { if(e.getSource()==bb[0]) { n2=n2*10; t1.setTextField((String.valueOf(n2)); } if(e.getSource()==bb[1]) { n2=n2*10+1; t1.setTextField((String.valueOf(n2)); } if(e.getSource()==bb[2]) { n2=n2*10+2; t1.setTextField((String.valueOf(n2)); } if(e.getSource()==bb[3]) { n2=n2*10+3; t1.setTextField((String.valueOf(n2)); } if(e.getSource()==bb[4]) { n2=n2*10+4; t1.setTextField((String.valueOf(n2)); } if(e.getSource()==bb[5]) { n2=n2*10+5; t1.setTextField((String.valueOf(n2)); } if(e.getSource()==bb[6]) { n2=n2*10+6; t1.setTextField((String.valueOf(n2)); } if(e.getSource()==bb[7]) { n2=n2*10+7; t1.setTextField((String.valueOf(n2)); } if(e.getSource()==bb[8]) { n2=n2*10+8; t1.setTextField((String.valueOf(n2)); } if(e.getSource()==bb[9]) { n2=n2*10+9; t1.setTextField((String.valueOf(n2)); } if(e.getSource()==mul) { t1.setTextField(" "); flag=1; } if(e.getSource()==div) { t1.setTextField(" "); flag=2; } if(e.getSource()==sum) { t1.setTextField(" "); flag=3; } if(e.getSource()==sub) { t1.setTextField(" "); flag=4; } if(e.getSource()==z) { t1.setTextField(" "); flag=5; } if(flag!=0) { flag1=flag2; flag2=flag; flag=0; n3=n1; n1=n2; n2=0; } switch(flag1) { case 1: {n1=n3*n1;t1.setTextField((String.valueOf(n1));break;} case 2: {n1=n3/n1;t1.setTextField((String.valueOf(n1));break;} case 3: {n1=n3+n1;t1.setTextField((String.valueOf(n1));break;} case 4: {n1=n3-n1;t1.setTextField((String.valueOf(n1));break;} case 5: {n1=n3;t1.setTextField((String.valueOf(n1));break;} } }}

Lord ganesh

Lord ganesh

sanjeetjha

sanjeetjha
balokova russia

sudoku program

//======================================================= // file SU_DU_KU.java // //====================================================== import java.applet.*; import java.awt.*; import java.awt.event.*; // //======================================================= public class SU_DU_KU extends Applet implements ActionListener { Button START,NEXT; TextField t[] =new TextField[81]; int a[][] =new int[9][9]; int b[][] =new int[9][9]; Font f=new Font("helvetica",Font.BOLD,30); //===============initialization of objects======================= public void init() { int i; Graphics g =new Graphics(); START=new Button(" CLICK START "); add(START); START.addActionListener(this); for(i=0;i<81;i++) { t[i] =new TextField(1); add(t[i]); } setBackground(new Color(78,50,100)); //default setting g.setColor(Color.red); for(i=0;i<81;i++) t[i].setText("0"); NEXT=new Button(" CLICK NEXT for NEW SUDUKU"); add(NEXT); NEXT.addActionListener(this); } //=================================================================== public void paint(Graphics g) { g.setColor(new Color(8,8,9)); g.fillRect(0,26,350,254); g.setColor(Color.red); g.fillRect(0,26,350,6); g.fillRect(0,112,350,6); g.fillRect(0,196,350,6); g.fillRect(0,280,350,6); g.fillRect(0,26,6,254); g.fillRect(108,26,6,254); g.fillRect(216,26,6,254); g.fillRect(324,26,6,254); g.setFont(f); } //=======================calling the interface======================== public void actionPerformed(ActionEvent e) { int i,j,k=0; if(e.getSource()==START) { //reading text from text field and assign to b[i][j] for(i=0;i<9;i++) for(j=0;j<9;j++) { a[i][j]=Integer.parseInt(t[k++].getText()); b[i][j]=a[i][j]; } call_sudu_ku( ); k=0; for(i=0;i<9;i++) for(j=0;j<9;j++) { t[k++].setText(String.valueOf(a[i][j])); } } if(e.getSource()==NEXT) //default setting for(i=0;i<81;i++) t[i].setText("0"); } //========================================================================== //===========================call_sudu_ku( )================================= public void call_sudu_ku( ) { int i,j,k,l; int m[]=new int[90]; int n[]=new int[90]; int count=0; int temp1,temp2; int p=0; for(i=0;i<9;i++) for(j=0;j<9;j++) { do { count ++; if(b[i][j]==0) { m[p] =i; n[p]=j; do { a[i][j]=a[i][j]+1; temp1=compare(i,j) ; }while(temp1==0); p=p+1; } temp2=0; if(a[i][j]==10) { temp2=1; a[i][j]=0; p=p-2; i=m[p]; j=n[p]; } }while(temp2==1); if(count==100) break; } } //=======================compare(int i,int j)================================== public int compare(int i,int j) { int k,l,temp; temp=1; // checking for horizontal for(k=0;k<9;k++) { if(a[i][j]==a[i][k]) if(j!=k) temp=0; } //checking for vertical for(k=0;k<9;k++) { if(a[i][j]==a[k][j]) if(i!=k) temp=0; } //checking for box 1 if(i<3 && j<3) { for(k=0;k<3;k++) for(l=0;l<3;l++) { if(i==k&&j==l); else if(a[i][j]==a[k][l]) temp=0; } } //checking for box 2 if(i<3 && j<6 &&j>2) { for(k=0;k<3;k++) for(l=3;l<6;l++) { if(i==k&&j==l); else if(a[i][j]==a[k][l]) temp=0; } } //checking for box 3 if(i<3 && j>5) { for(k=0;k<3;k++) for(l=6;l<9;l++) { if(i==k&&j==l) ; else if(a[i][j]==a[k][l]) temp=0; } } //checking for box 4 if(i>2 &&i<6 && j<3) { for(k=3;k<6;k++) for(l=0;l<3;l++) { if(i==k&&j==l); else if(a[i][j]==a[k][l]) temp=0; } } //checking for box 5 if(i>2&& i<6 && j<6 &&j>2) { for(k=3;k<6;k++) for(l=3;l<6;l++) { if(i==k&&j==l) ; else if(a[i][j]==a[k][l]) temp=0; } } //checking for box 6 if(i>2 && i<6 && j>5) { for(k=3;k<6;k++) for(l=6;l<9;l++) { if(i==k&&j==l); else if(a[i][j]==a[k][l]) temp=0; } } //checking for box 7 if(i>5&&j<3) { for(k=6;k<9;k++) for(l=0;l<3;l++) { if(i==k&&j==l); else if(a[i][j]==a[k][l]) temp=0; } } //checking for box 8 if(i>5 && j<6&&j>2) { for(k=6;k<9;k++) for(l=3;l<6;l++) { if(i==k&&j==l); else if(a[i][j]==a[k][l]) temp=0; } } //checking for box 9 if(i>5 &&j>5) { for(k=6;k<9;k++) for(l=6;l<9;l++) { if(i==k&&j==l); else if(a[i][j]==a[k][l]) temp=0; } } return temp; } }

calculator

//======================================================= // file calculator2.java // display lable textfield and button //====================================================== import java.applet.*; import java.awt.*; import java.awt.event.*; // //======================================================= public class calculator2 extends Applet implements ActionListener { Button bb[ ] =new Button[10]; Button sum,sub,mul,div,c,z; Button on,off,backspace; TextField t1; Label L1; int pre_no=0; int current_no=0; int n2=0; int n3=0; int pre_flag=0; int current_flag=0; int flag=0; int i; int check; //===============initialization of objects======================= public void init() { L1 =new Label("CALULATOR"); add(L1); t1=new TextField(22); add(t1); on=new Button("ON"); add(on); on.addActionListener(this); off=new Button("OFF"); add(off); off.addActionListener(this); backspace=new Button("backspace"); add(backspace); backspace.addActionListener(this); c=new Button("c"); add(c); c.addActionListener(this); for(i=0;i<10;i++) { bb[i] =new Button(String.valueOf(i)); add(bb[i]); bb[i].addActionListener(this); } sum =new Button("+"); add (sum); sum.addActionListener(this); sub =new Button("-"); add (sub); sub.addActionListener(this); mul =new Button("*"); add (mul); mul.addActionListener(this); div =new Button("%"); add (div); div.addActionListener(this); z=new Button("="); add(z); z.addActionListener(this); setBackground(Color.red); } public int number(int number,int k) { number=number*10+k; t1.setText(String.valueOf(number)); check=k; if(current_flag==5) { pre_flag=0; current_flag=0; pre_no=0; current_no=0;current_no=0; } return(number); } //=======================calling the interface======================== public void actionPerformed(ActionEvent e) { flag=0; if(e.getSource()==bb[0]) n2=number(n2,0); if(e.getSource()==bb[1]) n2=number(n2,1); if(e.getSource()==bb[2]) n2=number(n2,2); if(e.getSource()==bb[3]) n2=number(n2,3); if(e.getSource()==bb[4]) n2=number(n2,4); if(e.getSource()==bb[5]) n2=number(n2,5); if(e.getSource()==bb[6]) n2=number(n2,6); if(e.getSource()==bb[7]) n2=number(n2,7); if(e.getSource()==bb[8]) n2=number(n2,8); if(e.getSource()==bb[9]) n2=number(n2,9); if(e.getSource()==mul) { t1.setText(" "); flag=1; } if(e.getSource()==div) { t1.setText(" "); flag=2; } if(e.getSource()==sum) { t1.setText(" "); flag=3; } if(e.getSource()==sub) { t1.setText(" "); flag=4; } if(e.getSource()==z) { t1.setText(" "); flag=5; } if(e.getSource()==c) { t1.setText(" "); n2=0; if(current_flag==5) { pre_flag=0; current_flag=0; pre_no=0; current_no=0; } } if(e.getSource()==backspace) { n2=(n2-check)/10; t1.setText(String.valueOf(n2)); } if(flag!=0) { pre_flag=current_flag; current_flag=flag; pre_no=current_no; current_no=n2; n2=0;flag=0; if(current_flag ==5 && pre_flag==5) { pre_flag=0; current_flag=0; pre_no=0; current_no=0; } switch(pre_flag) { case 1: current_no=pre_no * current_no ; t1.setText(String.valueOf(current_no)); break; case 2: current_no=pre_no/current_no; t1.setText(String.valueOf(current_no)); break; case 3: current_no=pre_no+current_no; t1.setText(String.valueOf(current_no)); break; case 4: current_no=pre_no-current_no; t1.setText(String.valueOf(current_no)); break; case 5: current_no=pre_no; t1.setText(String.valueOf(current_no)); } } } }