Thursday, 19 March 2015

Introduction to APPLET in java


                  SMILELY  &  CRIEY  programmed in java

--------------------------------------------------------------------------------------

//Back again , this time with  SMILELY  &  CRIEY  programmed in java. You can know how to interface  init() and paint().                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    //         ..........HAPPY CODING

 

        import java.io.*;
        import java.awt.event.*;
        import java.util.Scanner;
        import java.awt.*;
import java.applet.*;
        /*<applet code="smile" width=150 height=140></applet>*/
       

        public class smile extends Applet implements ActionListener {
        int r1,t=0,m;
        Button b1;
        Button b2,b3;
       
            public void init()
            {
                Color k=new Color(120,89,90);
                setBackground(k);

                 b1=new Button("PRESS TO GET CRIEY ");
               
                b1.setBounds(1970,2580,160,120);
                b1.setBackground(Color.red);
                b1.setForeground(Color.blue);
                b1.addActionListener(this);
                add(b1);
               
                 b2=new Button("PRESS TO GET SMIELY ");
                add(b2);
                //b1.setBounds(970,2580,160,920);
                b2.setBackground(Color.red);
                b2.setForeground(Color.blue);
                b2.addActionListener(this);
               
                 b3=new Button("MY WORDS ");
                   
                    b3.setBounds(1970,2580,160,120);
                    b3.setBackground(Color.red);
                    b3.setForeground(Color.blue);
                    b3.addActionListener(this);
                    add(b3);



            }
           
           
   
            public void paint(Graphics g)
            {  
                if(t==0)
                {
                   
                    g.setColor(Color.yellow);
                    g.fillOval(340,180,250,250);   
                    g.setColor(Color.black);
                    g.fillOval(390,260,35,35);
                    g.setColor(Color.black);
                    g.fillOval(500,260,35,35);   
                    g.setColor(Color.black);
                    for(int i=0;i<9;i++)
                    {g.drawArc(400,305,130+i,68+i,180,180);}
                   
                    g.setColor(Color.yellow);
                    g.fillOval(740,180,250,250);   
                    g.setColor(Color.black);
                    g.fillOval(790,260,35,35);
                    g.setColor(Color.black);
                    g.fillOval(900,260,35,35);   
                    g.setColor(Color.black);//1300,435
                    for(int i=0;i<9;i++)
                    {g.drawArc(800,325,130+i,68+i,0,180);}
                    for(int i=0;i<6;i++)
                    g.drawArc(800,325+i,130,68,15,165);
                }
           
                   
               if(t==2)
               {Color k=new Color(120,89,90);
                setBackground(k);

                g.setColor(Color.yellow);
                g.fillOval(540,180,250,250);   
                g.setColor(Color.black);
                g.fillOval(590,260,35,35);
                g.setColor(Color.black);
                g.fillOval(700,260,35,35);   
                g.setColor(Color.black);
                for(int i=0;i<9;i++)
                {g.drawArc(600,305,130+i,68+i,180,180);}
               
               }
               if(t==1)
                {Color k=new Color(120,89,90);
                setBackground(k);

       
                    g.setColor(Color.yellow);
                    g.fillOval(640,180,250,250);   
                    g.setColor(Color.black);
                    g.fillOval(690,260,35,35);
                    g.setColor(Color.black);
                    g.fillOval(800,260,35,35);   
                    g.setColor(Color.black);//1300,435
                    for(int i=0;i<9;i++)
                    {g.drawArc(700,330,130+i,68+i,0,180);}
                    for(int i=0;i<6;i++)
                    g.drawArc(700,330+i,130,68,15,165);
                }
                   

               if(t==3)
               {//Color k=new Color(2,3,4);
                setBackground(Color.WHITE);
                   Font font = new Font("Serif", Font.PLAIN, 34);
                  g.setFont(font);
                  g.setColor(Color.blue);
                  g.drawString("THANK  YOU ", 550, 180);
                  g.setColor(Color.CYAN);
                  g.drawString("FOR ", 610, 230);
                  g.setColor(Color.GREEN);
                  g.drawString("WATCHING ", 550, 280);
                  g.setColor(Color.BLACK);
                  g.drawString(".....viswadeep ", 850, 450);


                 
               }
            }
       

public void actionPerformed( ActionEvent ae) {
               
                String str=ae.getActionCommand();
               
                if (ae.getSource() == b1)
                {t=1;
                repaint();//calling paint() function
                }
               
                if (ae.getSource() == b2)
                {t=2;
                repaint();//calling paint() function
                }
               
                if (ae.getSource() == b3)
                {t=3;
                repaint();//calling paint() function
                }
   
        }


}

Tuesday, 17 March 2015

create ur own heder file for password. so others cannot see output of ur program, make it private.

                                    BILL CALCULATION PROGRAM WITH PASSWORD ACCESS
                                 ----------------------------------------------------------------------------------------

//PLEASE COMMENT ON THIS PROGRAM 

It has to be done in two steps :-

STEP(1) :- Paste below code in NOTEPAD of  INCLUDE folder of  C or C++  compiler .As u run the program it asks password it is secret ..........but only for u  it is  888 .Save this notepad with "password.h" extension.
//////////////////////////////////////////////////////////////////////////////////////
int password()                           |
{                                                |       part of program
int c;                                          |             to be     
char o;                                       |       placed  in   the      TURBOC=> BIN=> INCLUDE
c='o'*8;                                     |           INCLUDE  
return c;                                    |        folder of turbo
}                                               |            C   or  C++.
/////////////////////////////////////////////////////////////////////////////////////


STEP(2) :- Place this code in new file and save it as we do generally by giving file name of  your choice.
=>Shop bill is available to products listed below :- "britaniya";"threeroses";"colgate";"cellofinegrip";"ricebag";"doormat";"rexona";"dove";"sunfloweroil";
"rin";"dairymilk";"fa";
=>Some prodducts may not have product name so u can enter amount from '1' to  '30' instead of product name.


************************************************************************************


#include<graphics.h>
#include<iostream.h>
#include <conio.h>
#include<password.h>
#include<dos.h>
#include<string.h>
#include<process.h>
class visu
{public:
int i,p,l,z;char c[20];
void i1(char a[20])
{
strcpy(c,a);
l=strlen(c);
cout<<"Quantity of product         :  ";cin>>p;
}
void p1()
{

char c1[10]="britaniya";char c2[13]="threeroses";
char  c3[8]="colgate";char c4[15]="cellofinegrip";
char  c5[8]="ricebag";char c6[8]="doormat";
char  c7[8]="rexona";char c8[6]="dove";
char  c9[15]="sunfloweroil";char c10[5]="rin";
char  c11[10]="dairymilk";char c12[3]="fa";
char  c13[2]="3";char c14[2]="1";char c15[2]="2";
char c16[2]="4";char c17[2]="5";char c18[2]="6";char c19[2]="7";
char c20[2]="8";char c21[2]="9";char c22[3]="10";
char  c23[3]="11";char c24[3]="12";char c25[3]="13";
char c26[3]="14";char c27[3]="15";char c28[3]="16";char c29[3]="17";
char c30[3]="18";char c31[3]="19";char c32[3]="20";
char  c33[3]="21";char c34[3]="22";char c35[3]="23";char c36[3]="24";char c37[3]="25";char c38[3]="26";char c39[3]="27";char c40[3]="28";char c41[3]="29";char c42[3]="30";
if(strcmp(c,c1)==0){i=10;}
else if(strcmp(c,c2)==0){i=45;}else if(strcmp(c,c3)==0){i=54;}
else if(strcmp(c,c4)==0){i=6;}else if(strcmp(c,c5)==0){i=1200;}
else if(strcmp(c,c6)==0){i=30;}else if(strcmp(c,c7)==0){i=18;}
else if(strcmp(c,c8)==0){i=30;}else if(strcmp(c,c9)==0){i=70;}
else if(strcmp(c,c10)==0){i=10;}else if(strcmp(c,c11)==0){i=10;}
else if(strcmp(c,c12)==0){i=120;}else if(strcmp(c,c13)==0){i=3;}
else if(strcmp(c,c14)==0){i=1;}else if(strcmp(c,c15)==0){i=2;}
else if(strcmp(c,c16)==0){i=4;}else if(strcmp(c,c17)==0){i=5;}
else if(strcmp(c,c18)==0){i=6;}else if(strcmp(c,c19)==0){i=7;}
else if(strcmp(c,c20)==0){i=8;}else if(strcmp(c,c21)==0){i=9;}
else if(strcmp(c,c22)==0){i=10;}if(strcmp(c,c23)==0){i=11;}
else if(strcmp(c,c24)==0){i=12;}else if(strcmp(c,c25)==0){i=13;}
else if(strcmp(c,c26)==0){i=14;}else if(strcmp(c,c27)==0){i=15;}
else if(strcmp(c,c28)==0){i=16;}else if(strcmp(c,c29)==0){i=17;}
else if(strcmp(c,c30)==0){i=18;}else if(strcmp(c,c31)==0){i=19;}
else if(strcmp(c,c32)==0){i=20;}
else if(strcmp(c,c33)==0){i=21;}else if(strcmp(c,c34)==0){i=22;}else if(strcmp(c,c35)==0){i=23;}else if(strcmp(c,c36)==0){i=24;}else if(strcmp(c,c37)==0){i=25;}else if(strcmp(c,c38)==0){i=26;}else if(strcmp(c,c39)==0){i=27;}else if(strcmp(c,c40)==0){i=28;}else if(strcmp(c,c41)==0){i=29;}else if(strcmp(c,c42)==0){i=30;}
//else{cout<<"PRODUCT IS NOT AVAILABLE";}
//else{i=0;}
}
void s(int z)
{for(int y=0;y<z-l;y++)
{cout<<" ";
}
}
void s1(int z)
{for(int y=0;y<z-1;y++)
{cout<<" ";
}
}

int o1()
{
int m;
setcolor(2);
settextstyle(2,0,7);
outtextxy(21,5,"product            Quantity           Amount");


m=i*p;
cout<<"\n\n\n     "<<c;s(30);cout<<p;s1(27);cout<<m;return m;

}

};
void main()
{visu v[20]; char f[20]="e"; int r,b;
 char g[20]="a";
clrscr();
int a=DETECT,d,i=1,u,m=0,z;
initgraph(&a,&d,"C:\\TurboC3\\BGI");
cout<<"\n\n\n\n\n\n\n\n\n\n\n                                 ";
cout<<"password please :  ";
cin>>b;
r=password();
//cout<<r;
if(r==b)
{clrscr();cleardevice();
while(strcmp(g,f)!=0)
{
cout<<"\nName of product/Rs          :  ";
cin>>g;
if(strcmp(g,f)!=0)
{
v[i].i1(g);
v[i].p1(); i++;
cout<<"\n***********************   Press e to get bill   *****************************";cout<<"\n";
}
else
{
cout<<"\ncheck wether particulars are True(1) or Not(0) :";
cin>>u;
if(u==1)
{
clrscr();cleardevice();
}
else{
exit(0);
}
}
}
line(18,5,560,5);
line(18,33,560,33);
line(18,5,18,33);
line(560,5,560,33);

for(int j=1;j<=i-1;j++)
{
z=v[j].o1();
m=m+z;
}
setcolor(15);
line(18,33,18,i*46);
line(560,33,560,i*46);
line(18,i*46,560,i*46);
cout<<"\n\n\n                                                  TOTAL :     ";
cout<<m;
line(18,i*46,18,i*46+56);
line(560,i*46,560,i*46+56);
line(18,i*46+56,560,i*46+56);
}
else{
cout<<"\n\n\n\n\n\n\n\n\n\n\n                                 ";
cout<<"wrong password try again";
}
getch();
}
************************************************************************************