Sunday, February 10, 2019

Match Making for you matrimony

Match making 

Matrimony 


Click above link to fill the form

 

Java program for String operations in swing





JAVA PROGRAM FOR String Operations in swing:



import java.awt.*;
import  java.lang.*;
import java.awt.event.*;
import javax.swing.*;

/*<applet code="StrOp" width=400 height=400></applet>*/

public class StrOp extends JApplet implements ActionListener
{
        JTextField text5;
       JTextField text4;
        JTextField text3;
       JTextField text2;
        JTextField text1;
        public void init()
        {
                Container contentPane=getContentPane();
                contentPane.setLayout(new GridLayout(5,2,40,40));
                JLabel enter=new JLabel("Enter String:");
                contentPane.add(enter);
                text1=new JTextField();
                contentPane.add(text1);
                JButton lower=new JButton("LOWER");
                lower.addActionListener(this);
                contentPane.add(lower);
                text2=new JTextField();
                contentPane.add(text2);
                JButton upper=new JButton("UPPER");
                upper.addActionListener(this);
                contentPane.add(upper);
                text3=new JTextField();
                contentPane.add(text3);
                JButton italic=new JButton("ITALIC");
         
                 italic.addActionListener(this);
                contentPane.add(italic);
                text4=new JTextField();
                text4.setFont(new Font("TimesNewRoman",Font.ITALIC,12));
                contentPane.add(text4);
                JButton bold=new JButton("BOLD");
                bold.addActionListener(this);
                contentPane.add(bold);
                text5=new JTextField();
                text5.setFont(new Font("TimesNewRoman",Font.BOLD,12));
                contentPane.add(text5);
       }
       public void actionPerformed(ActionEvent e)
       {
                String str=text1.getText();
                if(e.getActionCommand()=="LOWER")
                        text2.setText(str.toLowerCase());
                else if(e.getActionCommand()=="UPPER")
                        text3.setText(str.toUpperCase());
                else if(e.getActionCommand()=="ITALIC")
                        text4.setText(str);
                else if(e.getActionCommand()=="BOLD")
                        text5.setText(str);
       }
}












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



OUTPUT
*****************************************

Enter String     :  vijay

Lower              :  vijay

Upper              :  VIJAY
Italic                :  vijay
Bold                :   vijay

Java Program for Inheritance




JAVA PROGRAM FOR INHERITANCE:




import java.io.*;
 class Base
 {
     int a,b;
     void get( )
     {
         InputStreamReader ip=new InputStreamReader(System.in);
         BufferedReader br=new BufferedReader(ip);
         String ap;
         try
         {
            System.out.println("Enter Value of A:");
            ap=br.readLine( );
            a=Integer.parseInt(ap);

            System.out.println("Enter Value of B:");
            ap=br.readLine( );
            b=Integer.parseInt(ap);
           }
          catch(Exception e)
          {
            System.out.println(e);
           }
        }
    }
 class Derived extends Base
 {
    void disMin( )
    {
       if(a<b)
        System.out.println("Minimum Value is A:"+a);
       else
        System.out.println("Minimum Value is B:"+b);
       }
    void disMax( )
    {
       if(a>b)
         System.out.println("Maximum Value is A:"+a);
       else
         System.out.println("Maximum Value is B:"+b);
       }
   }
 class Inheritance
 {
   public static void main(String args[])
   {
      Derived dd=new Derived( );
      dd.get( );
      dd.disMin( );
      dd.disMax( );
    }
 }


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


OUTPUT:

*****************************************      
C:\vijay\advjava\jdk1.4\bin>java Base

Enter Value of A:
232
Enter Value of B:
236

Minimum Value is A:232
Maximum Value is B:236

C:\vijay\advjava\jdk1.4\bin>








Java program for square root




Java program for square root:



import java.awt.*;
import java.awt.event.*;
import java.io.*;

class SqRoot extends Frame implements ActionListener
 {
   TextField t1,t2;
   Label l1,l2;
   Button b1,b2;

   SqRoot()
   {
    setVisible(true);
    setTitle("Special Purpose Claculator");
    setSize(400,400);
  
      l1=new Label("Input no.");
      l2=new Label("Output");
    
      t1=new TextField(10);
      t2=new TextField(10);

      b1=new Button("Calculate");
      b2=new Button("Clear");
      b1.addActionListener(this);
      b2.addActionListener(this);

     Panel p1=new Panel( );
     p1.setLayout(new GridLayout(2,2));

     p1.add(l1);
     p1.add(t1);
     p1.add(l2);
     p1.add(t2);





     Panel p2=new Panel( );
     p2.setLayout(new FlowLayout( ));

     p2.add(b1);
     p2.add(b2);

     Panel p3=new Panel();
     p3.setLayout(new GridLayout(2,1));
     p3.add(p1);
     p3.add(p2);
    add(p3);

   }
  public void actionPerformed(ActionEvent ae)
  {
    try
    {
      if(ae.getSource( )==b1)
      {
        int n=Integer.parseInt(t1.getText( ));
        double y;
        y= Math.sqrt(n);
        t2.setText(""+y);
      }
   else
      {
        t1.setText("");
        t2.setText("");
     }
   }
     catch(Exception e)
     {
       System.out.println("Error..."+e);
        dispose( );
      }

  }
   public static void main(String args[])
   {
     SqRoot s=new SqRoot( );
     s.validate( );
   }
}

Java program for hash table


import  java.util.*;
import java.lang.*;
import java.io.*;
class   hashtable
{
        static Hashtable<String,Double> stud=new Hashtable<String,Double>();
              public  static void main(String args[])
        {
                BufferedReader br=new BufferedReader(new InputStreamReader(System.in));               
                do                {
                        System.out.println("****************MENU*****************");
                        System.out.println("1:ACCEPT RECORD\n2:DISPLAY ALL                      RECORDS\n3:FIND HIGHEST\n4:EXIT");
                        System.out.println("\nEnter your choice:");
                        int ch=0;
                        try
                        {
                                ch=Integer.parseInt(br.readLine());
                        }
                        catch(IOException e)
                        {
                                System.out.println(e);
                        }
                        switch(ch)
                        {
                                case 1:
                                        accept();
                                        break;
                                case 2:
                                        displayall();
                                        break;
                                case 3:
                                        fhigh();
                                        break;
                             




                                    case 4:
                                        System.exit(0);
                                default:
                                        System.out.println("You entered wrong choice! TRY AGAIN!!");
                                        break;
                         }
               }while(true);
      }
               public static void accept()
               {
                        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
                        String name="";
                        Double d=0.0;
                        System.out.println("Enter the name:");
                        try
                        {
                                name=br.readLine();
                                System.out.println("Enter the percentage:");
                                d=Double.parseDouble(br.readLine());
                        }
                        catch(IOException e)
                        {
                                System.out.println(e);
                        }

                        stud.put(name,d);
                }
                public static void displayall()
                {
                        Enumeration keys=stud.keys();
                        while(keys.hasMoreElements())
                        {
                                String key=(String)keys.nextElement();
                                System.out.println(key+"="+stud.get(key));
                        }
                }
                public static void fhigh()
                {
                      






                         Double max=0.0;
                        Enumeration keys=stud.keys();
                        while(keys.hasMoreElements())
                        {
                                String key=(String)keys.nextElement();
                                if(max<stud.get(key))
                                        max=stud.get(key);
                        }      
                        System.out.println("Highest Marks="+max);
                }
        
}
                       

*****************************************************************
OUTPUT
******************************************************************



Enter your choice:
1
Enter the name:
vijay
Enter the percentage:
71
****************MENU*****************
1:ACCEPT RECORD
2:DISPLAY ALL RECORDS
3:FIND HIGHEST
4:EXIT

Enter your choice:
1
Enter the name:
ajay
Enter the percentage:
77
****************MENU*****************
1:ACCEPT RECORD
2:DISPLAY ALL RECORDS
3:FIND HIGHEST
4:EXIT

Enter your choice:
1
Enter the name:
 atul
Enter the percentage:
81
****************MENU*****************
1:ACCEPT RECORD
2:DISPLAY ALL RECORDS
3:FIND HIGHEST
4:EXIT

Monday, February 4, 2019

Habits of all Successful People

Habits of all Successful People:




1. They Set GOALS.
2. They Take Responsibility For Their Life.
3. They Have Great Self Discipline
4. They Are Obsessed With Self Development
5. They Read. A LOT!
6. They Manage Their Time Well
7. They Take Risks!
8. They Keep Going When They Suffer Failure & Setbacks
9. They Find A Way To Win
10. They Do What They Love



"When you sweat  a lot in time of peace you bleed less in times of war."



Ten skills which are hard to learn, but which will make you successful:
1. Speaking up (Public Speaking)
2. Being honest with yourself
3. Having confidence
4. Listening
5. Managing your time
6. Stop whining
7. Staying present in the moment
8. Being consistent
9.  Getting enough sleep
10. Having empathy 

Five Elements that lead to Success


Five elements that lead to Success are:

1: Idea

2: Team

3: Business Model

4: Funding

5: Timing




Timing is very essential to Success

Think what are you are going to get at the end of the process and happy sacrifice now knowing they will be rewarded latter .Keep Going.




Thursday, January 31, 2019

Life teaches us


In life, carrier selection is very important in life.


If we know what we can do then it gives us a direction for our life. Trust yourself to choose what's right for you. For that we set a goal and we start working on it. To achieve that goal we start focusing and our life becomes automatically a healthy and wealthy. Dream a life with thinking of future in mind. Dream creates a desires. Desires create determination, which leads us to our destiny. After our achievements we will get success. Live a life which will set inspiration for others. It will be not so easy there will be many obstacles in your life don't get demotivate by it, fight against it after looking back you will say yourself that this obstacle is very small compared to present. Journey of life will collect many memories and many contacts with a confidence. Mistakes may be happened so don't be afraid learn from it and try not to repeat it. A mistake should be your teacher, not your attacker. A mistake is a lesson, not a loss. It is temporary not a dead end. Life and time are best teachers. Life teaches us the use of time and time teaches us the value of life. Life is like a book, some chapters are happy, some are exciting and some are sad. But if you never turn the page, you will never know what the next chapter holds.

In life there is three needs Roti(food) ,kapda (Clothes) and makaan (house)
but there is one more thing that is education 
Education is never stolen from you
Knowledge is never absolute
Never stop learning because learning never stops.
Example if you once learn cycling or swimming ,you never forget if you do cycling after ten years also.
When you will chase knowledge numbers will always follow.


Saturday, January 26, 2019

Sys pro program for CPU scheduling : Priority algo. - Non premptive


PPRIIORITY.C



/* CPU scheduling : Priority algo. - Non premptive ................... */
// jobQ maintained as ascending order priority Q (1st job-highest priority)
#include<stdlib.h>
#include<stdio.h>
#define newnode (struct node *)malloc(sizeof(struct node))
struct node
{ int jobno,time,proty;  // priority
  struct node *next;
}*JOBQ=NULL;

int job=0;

void erase()
{ struct node *S;
  while(JOBQ!=NULL) { S=JOBQ;  JOBQ=JOBQ->next;  free(S);  }
  job=0;
}

struct node *Append(struct node *F)
{ struct node *s,*t,*s1=NULL;
  t=newnode;        t->next=NULL;
  t->jobno=++job;   t->time=0;

  do  // validation check for job time
  {  printf("\nJOB %d - CPU burst : ",job);
     fflush(stdin); scanf("%d",&t->time);
     if(t->time<=0) printf("\nJob time should be > 0");
  }while(t->time<=0);

  do  // validation check for priority range 1-5
  {  printf("\t Priority : ",job);
     fflush(stdin);  scanf("%d",&t->proty);
     if(t->proty<1 || t->proty >5) printf("\nPriority range is 1(H) to 5(L) ");
  }while(t->proty<1 || t->proty >5);

  if(F==NULL)  F=t;    // JOBQ empty, so this is 1st job
  else    // priority wise insert (acsending oreder priority)
  {  for(s=F; s!=NULL; s1=s, s=s->next)  // find position
     { if(t->proty < s->proty) break;
     }
     t->next=s;  // insert before s
     if(s1==NULL) F=t;  // added before 1st node
     else s1->next=t; // inbetween position
  }
  return F;
}

void CreateJOBQ()
{ struct node *S;   int i,n;
  printf("\nHow many jobs? "); scanf("%d",&n);
  if(n<=0) { printf("\nError : No. of Jobs should be > 0."); return; }

  if(JOBQ!=NULL) erase(JOBQ);

  for(i=1;i<=n;i++)  JOBQ=Append(JOBQ);
}

void DisplayJOBQ()  // sorted on priority
{struct node *T;
  if(JOBQ==NULL) printf("\nJOB Q is Empty!");
  else
  { printf("\n JOB  Time  Priority");
    for(T=JOBQ;T!=NULL;T=T->next) printf("\n J%d : %3d %4d",T->jobno,T->time,T->proty);
  }
}

void delFstNode() // deletes 1st job(highest priority) from JOBQ
{struct node *t;
   t=JOBQ; JOBQ=JOBQ->next;
   free(t);
}

void ExecuteJOBQ()  // Shortest Job First
{ struct node *T,*S=NULL,*t1;  int time=0; char choice;

  if(JOBQ==NULL) { printf("\nJOB Q is Empty!"); return; }

  printf("\nclock CPU   JOBQ ");
  printf("\n%3d  -idle-",time);
  for(T=JOBQ; T!=NULL; T=T->next) printf(" J%d(%d) ",T->jobno,T->time);  // print JOBQ

  while(JOBQ!=NULL)
  {
    printf("\n%3d  J%d(%d) |--",time,JOBQ->jobno,JOBQ->time); // cpu allocated
    time+=JOBQ->time; // increment clock
    delFstNode();  // job finished
    for(T=JOBQ; T!=NULL; T=T->next) printf(" J%d(%d:%d) ",T->jobno,T->proty,T->time);  // print JOBQ

    printf(" --|  Add New Job(y/n)? ");  choice=getche();
    if(choice=='y' || choice=='Y')  JOBQ=Append(JOBQ);
  }
  printf("\n%3d  -idle-",time);
}

char menu()
{ char choice='a';
  clrscr();
  printf("\n< Priority : NonPreemptive > ");
  printf("\nC: Create \nD: Display \nE: Execute \nX: exit");
  printf("\nEnter your choice : ");  choice=getche();
  return toupper(choice);
}

void main()
{
  while(1)
  { switch(menu())
    { case 'X' : erase(); exit(0);  // release memory allocated to JOBQ
      case 'C' : CreateJOBQ();  break;
      case 'D' : DisplayJOBQ(); break;
      case 'E' : ExecuteJOBQ(); break;
      default  : printf("\7 Invalid Choice!");
    }
    printf("\npress any key to continue...");    getch();
  }
}









ASMB2.C

#include<stdio.h>
#include<string.h>
#include<conio.h>
#include<stdlib.h>

struct symtab
{
    char name[10];
    int used,declared,addr,length,value;
}s[10];

int symtab_cnt;

int check_if_valid_opode(char tok[]);

int search_into_symtab(char *st)
{
    int i;
    for(i=0;i<symtab_cnt;i++)
        if(strcmpi(st,s[i].name)==0)
            return i;
    return -1;
}


char optab[][10]={"stop","add","sub","mult","mover","movem","comp","bc",
             "div","read","print"};
char regtab[][6]={"areg,","breg,","creg,","dreg,"};
char oprtab[][6]={"le,","lt,","eq,","gt,","ge,","any,"};
char adtab[][6]={"start","end","ltorg","origin"};

int optab_cnt=11;
int regtab_cnt=4;
int oprtab_cnt=6;
int adtab_cnt=4;



void display()
{
    int m;
    for(m=0;m<symtab_cnt;m++)
        if(s[m].used == 1 && s[m].declared == 0)
            printf("\nSymb %s used but not defined",s[m].name);
        else if(s[m].used == 0 && s[m].declared == 1)
            printf("\nSymb %s defined but not used",s[m].name);
    getch();
}



main(int argc,char *argv[])
{

    FILE *fp;
    char *w[4],*error[15];
    char str[80],line[80];
    int notok,i,p=0,k,j,cnt=0,h;
    clrscr();
    fp=fopen(argv[1],"r");
    if(fp==NULL)
    {
        printf("\nFile can not be opened...");
        getch();
        exit(1);
    }

    for(i=0;i<4;i++)           //Allocating memory to token variables
        w[i]=(char *)malloc(10);

    cnt=0;
    while(fgets(str,80,fp))
    {
        cnt++;
        printf("%d : %s",cnt,str);
        notok=sscanf(str,"%s%s%s%s",w[0],w[1],w[2],w[3]);
        switch(notok)
        {

            case 2:k=check_if_valid_opcode(w[0]);
                if(k==9||k==10)
                {
                    h=search_into_symtab(w[1]);
                    if(h==-1)
                    {
                        strcpy(s[symtab_cnt].name,w[1]);
                        s[symtab_cnt++].used=1;
                    }
                    continue;
                }
                break;

            case 3:k=check_if_valid_opcode(w[0]);.

                if(k>=1&&k<=8)
                {
                    h=search_into_symtab(w[2]);
                    if(h==-1)
                    {
                        strcpy(s[symtab_cnt].name,w[2]);
                        s[symtab_cnt++].used=1;
                    }
                    continue;
                }

                if(strcmpi(w[1],"ds")==0 || strcmpi(w[1],"dc")==0)
                {
                    h=search_into_symtab(w[0]);
                    if(h==-1)
                    {
                        strcpy(s[symtab_cnt].name,w[0]);
                        s[symtab_cnt++].declared=1;
                    }
                    else
                    {
                        if(s[h].declared==0)
                        {
                            s[h].declared=1;
                        }
                        else
                            printf("Multiple declaration");
                    }
                }
                break;

            case 4:h=search_into_symtab(w[0]);
                if(h==-1)
                {
                    strcpy(s[symtab_cnt].name,w[0]);
                    s[symtab_cnt++].declared=1;
                }
                break;
        }

    }
    display();

    getch();

}


int check_if_valid_opcode(char tok[])
{
    int i;
    for(i=0;i<optab_cnt;i++)
        if((strcmpi(tok,optab[i]))==0)
            return i;
    return -1;
}








C++ Programs Questions and answers Solved it

Solve C++ programs Questions and answers:

 



1)Which C++ header file(s) will be essentially required to be included to run /execute the following C++ code:

 void main()
{
     char Msg[ ]="Sunset Gardens";
     for (int I=5;I<strlen(Msg);I++)
     puts(Msg);
 }


Ans : stdio.h, string.h

 

Featured posts

Mongolia

 Mongolia! Mongolia is a vast and sparsely populated country in East Asia, known for its stunning natural beauty, rich history, and unique c...

Popular posts