Monday, 25 August 2014

SUDOKU PROGRAM

I HAVE CODED THIS PROGRAM USING JAPPLET THE EXCUTION OF THIS PROGRAM CAN BE DONE BY USING ECLIPSE,NETBEANS.

MAIN.JAVA
package sudokiller;


public class Main {
    
    /**
     * Creates the GUI with a default puzzle.
     * @params args Command-line arguments (unused)
     */
    public static void main(String[] args) {
        int[][] board = {{0, 6, 0, 1, 0, 4, 0, 5, 0},
                         {0, 0, 8, 3, 0, 5, 6, 0, 0},
                         {2, 0, 0, 0, 0, 0, 0, 0, 1},
                         {8, 0, 0, 4, 0, 7, 0, 0, 6},
                         {0, 0, 6, 0, 0, 0, 3, 0, 0},
                         {7, 0, 0, 9, 0, 1, 0, 0, 4},
                         {5, 0, 0, 0, 0, 0, 0, 0, 2},
                         {0, 0, 7, 2, 0, 6, 9, 0, 0},
                         {0, 4, 0, 5, 0, 8, 0, 7, 0}};
        
        new SwingSudoKiller(new SwingSudokuBoard(board));
    }   
}



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

SUDOKILLER.JAVA

package sudokiller;

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

/**
 * This class represents a graphical Sudoku board.
 * It is mostly a two-dimensional <code>JTextField<code> array
 * providing all the functionality of a <code>SudokuBoard<code> object.
 * Board cells are identified by their row and column and are zero-indexed.
 *
 */
public class SwingSudokuBoard extends SudokuBoard {
    private JTextField[][] cells;          // Graphical game board
    private JPanel panel = new JPanel();   // Container

    /**
     * Draws an empty board.
     * @param size Number of rows and columns of the board.
     */
    public SwingSudokuBoard(int size) {
        super(size);
        cells = new JTextField[size][size];
        panel.setLayout(new GridLayout(size, size));
        for (int row = 0; row < size; row++) {
            for (int col = 0; col < size; col++)  {
                cells[row][col] = new JTextField(1);
                panel.add(cells[row][col]);
            }
        }
    }

    /**
     * Draws and initializes the board.
     * @param board Array to initialize the board contents.
     */
    public SwingSudokuBoard(int[][] board) {
        this(board.length);
        for (int row = 0; row < size; row++) {
            for (int col = 0; col < size; col++) {
                setCell(board[row][col], row, col);
            }
        }
    }
    
    /**
     * Puts a number into a specific text field.
     * @param num Number to put into the text field (cell).
     * @param row Cell's row.
     * @param col Cell's column.
     */
    public void setCell(int num, int row, int col) {
        super.setCell(num, row, col);
        String text = (num == EMPTY) ? "" : String.valueOf(num);
        cells[row][col].setText(text);
    }
    
    /**
     * Returns the number contained in a specific text field (cell).
     * @param row Cell's row.
     * @param col Cell's column.
     * @return The number contained in the cell.
     */
    public int getCell(int row, int col) {
        int cell;

        try {
            cell = Integer.parseInt(cells[row][col].getText());
        }
        catch (NumberFormatException e) {
            cell = EMPTY;
        }
        return cell;
    }
    
    /**
     * Returns the JPanel containing the board.
     * @return Returns the board container.
     */
    public JPanel getPanel() {
        return panel;
    }
}


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

SUDOKUBOARD.JAVA

package sudokiller;

/**
 * This is the base class for implementing a Sudoku board.
 * It mostly is a two-dimensional <code>int<code> array and provides
 * basic methods for getting/setting cells contents. Board cells are identified
 * by their row and column and are zero-indexed.
 * 
 */
public class SudokuBoard {
    final int EMPTY = 0;      // Empty cells marker
    final int size;           // Size of the board (number of rows and columns)
    final int box_size;       // Size of the inner boxes

    private int[][] board;    // 2D array representing the game board

    /**
     * Creates an empty board.
     * @param size Number of rows and columns of the board.
     */
    public SudokuBoard(int size) {
        board = new int[size][size];
        this.size = size;
        this.box_size = (int) Math.sqrt(size);
    }
    
    /**
     * Creates and initializes the board.
     * @param board Array to initialize the board contents.
     */
    public SudokuBoard(int[][] board) {
        this(board.length);
        this.board = board;
    }
    
    /**
     * Puts a number into a specific cell.
     * @param num Number to put into the board cell.
     * @param row Cell's row.
     * @param col Cell's column.
     */
    public void setCell(int num, int row, int col) {
        board[row][col] = num;
    }

    /**
     * Returns the number contained in a specific cell.
     * @param row Cell's row.
     * @param col Cell's column.
     * @return The number contained in the cell.
     */
    public int getCell(int row, int col) {
        return board[row][col];
    }
}


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

SWINGSUDOKUBOARD.JAVA

package sudokiller;

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

/**
 * This class represents a graphical Sudoku board.
 * It is mostly a two-dimensional <code>JTextField<code> array
 * providing all the functionality of a <code>SudokuBoard<code> object.
 * Board cells are identified by their row and column and are zero-indexed.
 *
 */
public class SwingSudokuBoard extends SudokuBoard {
    private JTextField[][] cells;          // Graphical game board
    private JPanel panel = new JPanel();   // Container

    /**
     * Draws an empty board.
     * @param size Number of rows and columns of the board.
     */
    public SwingSudokuBoard(int size) {
        super(size);
        cells = new JTextField[size][size];
        panel.setLayout(new GridLayout(size, size));
        for (int row = 0; row < size; row++) {
            for (int col = 0; col < size; col++)  {
                cells[row][col] = new JTextField(1);
                panel.add(cells[row][col]);
            }
        }
    }

    /**
     * Draws and initializes the board.
     * @param board Array to initialize the board contents.
     */
    public SwingSudokuBoard(int[][] board) {
        this(board.length);
        for (int row = 0; row < size; row++) {
            for (int col = 0; col < size; col++) {
                setCell(board[row][col], row, col);
            }
        }
    }
    
    /**
     * Puts a number into a specific text field.
     * @param num Number to put into the text field (cell).
     * @param row Cell's row.
     * @param col Cell's column.
     */
    public void setCell(int num, int row, int col) {
        super.setCell(num, row, col);
        String text = (num == EMPTY) ? "" : String.valueOf(num);
        cells[row][col].setText(text);
    }
    
    /**
     * Returns the number contained in a specific text field (cell).
     * @param row Cell's row.
     * @param col Cell's column.
     * @return The number contained in the cell.
     */
    public int getCell(int row, int col) {
        int cell;

        try {
            cell = Integer.parseInt(cells[row][col].getText());
        }
        catch (NumberFormatException e) {
            cell = EMPTY;
        }
        return cell;
    }
    
    /**
     * Returns the JPanel containing the board.
     * @return Returns the board container.
     */
    public JPanel getPanel() {
        return panel;
    }
}


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

SWINGSUDOKILLER.JAVA

package sudokiller;

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

/**
 * Graphical Sudoku game solver.
 * The user should fill the board with the puzzle to solve and click the
 * 'Start' button (or type 'ALT-s') to get the solution.
 *
 */
public class SwingSudoKiller extends SudoKiller {

    /**
     * Draw the game board.
     * @param ssb The puzzle to solve.
     */
    public SwingSudoKiller(SwingSudokuBoard ssb) {
        super(ssb);
        final JPanel panel = ssb.getPanel();

        Runnable runner = new Runnable() {
            public void run() {
                final JFrame frame = new JFrame("SudoKiller");
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

                ActionListener al = new ActionListener() {
                    public void actionPerformed(ActionEvent ae) {
                        if (! guess(0, 0))
                            JOptionPane.showMessageDialog(frame, "Solution not found!");
                    }
                };
                frame.setLayout(new GridBagLayout());
                addComponent(frame, panel, 0, 0, 1, 1);
                
                JButton b = new JButton("Start!");
                b.setMnemonic(KeyEvent.VK_S);
                b.addActionListener(al);
                addComponent(frame, b, 0, 1, 1, 1);

                frame.setSize(240, 280);
                frame.setVisible(true);
            }
        };
        EventQueue.invokeLater(runner);
    }
    
    /**
     * Add a component to the GUI.
     * @param container Container to add the component to.
     * @param component The component to be added.
     * @param gridx Horizontal cell position inside the grid.
     * @param gridy Vertical cell position inside the grid.
     * @param gridwidth Number of cells in a row for the text field.
     * @param gridheight Number of cells in a column for the text field.
     */
    private static void addComponent(Container container, Component component,
        int gridx, int gridy, int gridwidth, int gridheight) {
        Insets insets = new Insets(0, 0, 0, 0);
        GridBagConstraints gbc = new GridBagConstraints(gridx, gridy, gridwidth,
                gridheight, 1, 1, GridBagConstraints.CENTER,
                GridBagConstraints.BOTH, insets, 0, 0);
        container.add(component, gbc);
    }
}
-----------------------------------------------------------------------------------------

Friday, 4 October 2013

DM FINDING MISSING VALUE CODE IN JAVA

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

public class Finder {

/**
* @param args
*/
public static void main(String[] args) {
String csvFile = "E:/Documents and Settings/student/Desktop/sample data 1.csv";
BufferedReader br = null;
String line = "";
String cvsSplitBy = ",";
String[] reader;
File file = new File("E:/Documents and Settings/student/Desktop/sample data without nulls.csv");
FileWriter fw = null;
int count=0;
try {
fw = new FileWriter(file.getAbsoluteFile());

BufferedWriter bw = new BufferedWriter(fw);
// if file doesnt exists, then create it
if (!file.exists()) {
file.createNewFile();
}
br = new BufferedReader(new FileReader(csvFile));
while ((line = br.readLine()) != null) {
        // use comma as separator
reader = line.split(cvsSplitBy);
//System.out.println("Age " + country[1]  + "Marital Status" + country[3]);
for(int i=0;i<5;i++){
if(reader[i].length()==0) {
reader[i]="missing";
count++;
}
}
bw.write(reader[0]+","+reader[1]+","+reader[2]+","+reader[3]+","+reader[4]+"\n");
}
bw.close();
System.out.println("Number of missing values="+count+"Done");
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();

 finally {
if (br != null) {
try {
br.close();
} catch (IOException e) {
e.printStackTrace();
}
}
 }
}
}


DM APRIORI ALGORITHM CODE IN JAVA


import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;


public class AprioriAlgo {

/**
* author: shwetha

* Execution:
* Enter Minimum Support.....
* 3
* Enter Transactions.....Bread,Milk
* Bread,Diaper,Beer,Eggs
* Milk,Diaper,Beer,Cola
* Bread,Milk,Diaper,Beer
* Bread,Milk,Diaper,Cola

*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner in=new Scanner(System.in);
ArrayList<String> al=new ArrayList<String>();
ArrayList<String> out=new ArrayList<String>();
ArrayList<String> dup=new ArrayList<String>();
ArrayList<String> mutex=new ArrayList<String>();
int n=1,y=0,cnt;
int[] len=new int[10];
int minsupport;
String str;
String[] temp,temp1;
String[][] splitstr = new String[10][10];
int x=0,k=0,z=0,p=0;
System.out.println("Enter Minimum Support.....");
minsupport=in.nextInt();
System.out.print("Enter Transactions.....");
//in.reset();
in.nextLine();
while((str=in.nextLine()).length()!=0){
temp=str.split(",");
len[y++]=temp.length;
for(int i=0;i<temp.length;i++){
splitstr[x][i]=temp[i];
if(!al.contains(temp[i]))
al.add(temp[i]);
out.add(temp[i]);
}
x++;
}
//minsupport=(int) ((x-1)*0.7);
//minsupport=3;
Collections.sort(al);
boolean test=true;
while(test){
System.out.println("\nCandidate "+n+" Item set");
System.out.print("\nItems\t Support");
out.clear();
for(String s:al){
temp=s.split(",");
System.out.print("\n"+s);
y=0;
for(int i=0;i<x;i++){
z=0;
for(int j=0;j<temp.length;j++){
for(k=0;k<len[i];k++){
if(temp[j].equals(splitstr[i][k])) z++;
}
}
if(z==temp.length)y++;
}
if(y>=minsupport){
out.add(s);
if(n==1)
dup.add(s);
}
else
mutex.add(s);
System.out.print("\t"+y);
}
n++;
al.clear();
for(int i=0;i<out.size();i++){
for(int j=i;j<dup.size();j++){
if(!out.get(i).contains(dup.get(j))){
al.add(out.get(i)+","+dup.get(j));
}
}
}
for(int i=0;i<al.size();i++){
temp=al.get(i).split(",");
for(int j=i+1;j<al.size();j++){
cnt=0;
temp1=al.get(j).split(",");
for(k=0;k<temp.length;k++){
if(al.get(i).contains(temp1[k])) cnt++;
}
if(cnt==3){
al.remove(j);
}
}
}
//System.out.println(al);

for(int i=0;i<mutex.size();i++){
temp=mutex.get(i).split(",");
for(int j=0;j<al.size();j++){
temp1=al.get(j).split(",");
p=0;
for(k=0;k<temp1.length;k++){
for(z=0;z<temp.length;z++){
if(temp1[k].equals(temp[z])) {
p++;
break;
}
}
//if(p==temp.length)break;
}
if(p==temp.length){al.remove(j);
//System.out.println("yay");
}
}
}
//System.out.println(mutex);
if(out.size()==0)
test=false;
}
}

}

Thursday, 4 July 2013

BINARY TREE TRAVERSAL TYPES

      

         1.  PREORDER 


  •  ROOT OF THE TREE
  •  LEFT SUBTREE
  •  RIGHT SUBTREE

       2. POSTORDER

  •   LEFT SUBTREE
  •   RIGHT SUBTREE
  •   ROOT OF THE TREE

      3. INORDER

  • LEFT SUBTREE
  • ROOT OF THE TREE
  • RIGHT SUBTREE 

Monday, 3 June 2013

Java thread program for clock using JApplet

import java.awt.*;
import java.util.*;import java.text.DateFormat;

@SuppressWarnings("serial")
public class Clock  extends java.applet.Applet implements Runnable
{
      private Thread threadClock=null;
      public void init()
      {
            setBackground(Color.white);
      }
      public void start()
      {
            if(threadClock==null)
            {
                  threadClock=new Thread(this,"CLOCK");
                  threadClock.start();
                 
            }
      }
      public void run()
      {
            Thread threadCurrent= Thread.currentThread();
            while(threadClock==threadCurrent){
                  repaint();
                  try
                  {
                        Thread.sleep(1000);
                  }
                  catch(InterruptedException e)
                  {
                 }
      }
      }
             
            public void paint(Graphics g)
            {
                  Font font=new Font("arial",Font.BOLD,28);
                  g.setFont(font);
                  g.setColor(Color.blue);
                  Calendar calci= Calendar.getInstance();
                  Date CurrentTime= calci.getTime();
                  DateFormat dtFormat= DateFormat.getTimeInstance();
                  g.drawString(dtFormat.format(CurrentTime),95,100);
            }
           
            public void stop()
            {
           
                  threadClock=null;
            }
     
     
           
      }
     
                 
                 




Saturday, 11 May 2013

Java application for simple calculator using swings


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

public class Calculator extends JFrame implements ActionListener,Runnable
{
  JButton bnum[];
  JButton bback,bce,bc;
  JButton bop[],jdb;
  JLabel jl;
  JTextField tf;
  JPanel p1,p2,p3;
  JDialog jd;
  double d1,d2,d3;
  //long n1,n2,n3;
  boolean frac=false;
  char op;
  boolean opc=false,ope=false;
  public void run()
  {
    while(true)
    {
      char ch=getTitle().charAt(0);
      setTitle(getTitle().substring(1,getTitle().length())+Character.toString(ch));
      try{
       Thread.sleep(200);
      }catch(InterruptedException ie){
       System.out.println(ie);
      }
    }
  }
  public Calculator(String str)
  {
    super(str);
    bnum=new JButton[10];
    jd=new JDialog(this,"Message",true);
    jdb=new JButton("OK");
    jl=new JLabel();
    jd.setLayout(new FlowLayout());
    jdb.setMargin(new Insets(2,5,2,5));
    jd.add(jl); jd.add(jdb);
    jdb.addActionListener(this);
    for(int i=0;i<10;i++)
      bnum[i]=new JButton(Integer.toString(i));
    bback=new JButton("Back");
    bce=new JButton("CE");
    bc=new JButton("C");
    p2=new JPanel();
    p2.setLayout(new FlowLayout());
    p2.add(bback);
    p2.add(bce);
    p2.add(bc);
    tf=new JTextField(15);
    p1=new JPanel();
    p1.add(tf);
    tf.setEditable(false);
    tf.setHorizontalAlignment(JTextField.RIGHT);
    tf.setText("0.");
    tf.setBackground(Color.white);
    tf.setFont(new Font("Dialog",Font.BOLD,12));
    //System.out.println(tf.getFont());
    bop=new JButton[10];
    bop[0]=new JButton("+");
    bop[1]=new JButton("-");
    bop[2]=new JButton("*");
    bop[3]=new JButton("/");
    bop[4]=new JButton(".");
    bop[5]=new JButton("=");
    bop[6]=new JButton("%");
    bop[7]=new JButton("Sqrt");
    bop[8]=new JButton("1/x");
    bop[9]=new JButton("+/-");
    for(int i=0;i<10;i++){
      bop[i].setMargin(new Insets(2,2,2,2));
      bop[i].addActionListener(this);
    }
    p3=new JPanel();
    p3.setLayout(new GridLayout(4,5,5,5));
    p3.add(bnum[1]);
    p3.add(bnum[2]);
    p3.add(bnum[3]);
    p3.add(bop[0]);
    p3.add(bop[7]);
    p3.add(bnum[4]);
    p3.add(bnum[5]);
    p3.add(bnum[6]);
    p3.add(bop[1]);
    p3.add(bop[8]);
    p3.add(bnum[7]);
    p3.add(bnum[8]);
    p3.add(bnum[9]);
    p3.add(bop[2]);
    p3.add(bop[6]);
    p3.add(bnum[0]);
    p3.add(bop[9]);
    p3.add(bop[4]);
    p3.add(bop[3]);
    p3.add(bop[5]);
    Container c=getContentPane();
    c.setLayout(new FlowLayout());
    c.add(p1);
    c.add(p2);
    c.add(p3);
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    setResizable(false);
    for(int i=0;i<=6;i++)
      bop[i].setFont(new Font("Dialog",Font.BOLD,13));
    for(int i=0;i<10;i++){
      bnum[i].addActionListener(this);
      bnum[i].setMargin(new Insets(2,10,2,10));
    }
    bce.addActionListener(this);
    bc.addActionListener(this);
    bback.addActionListener(this);
  }
  public void actionPerformed(ActionEvent ae)
  {
    String s=tf.getText();
    String str;
    if(!frac)
      str=s.substring(0,s.length()-1);
    else
      str=s;
    if(ae.getSource()==bback)
    {
      if(frac){
       if(str.charAt(str.length()-1)=='.')
        frac=false;
       else tf.setText(str.substring(0,str.length()-1));
      }
      else{
      if(!str.equals("0"))
       tf.setText(str.substring(0,str.length()-1)+".");
      }
      if(tf.getText().equals("."))
       tf.setText("0.");
    }
    else if(ae.getSource()==bce)
    {
      tf.setText("0.");
      frac=false;
      opc=false;
    }
    else if(ae.getSource()==bc)
    {
      tf.setText("0.");
      d1=0;
      d2=0;
      frac=false;
      opc=false;
      ope=false;
    }
    else if(ae.getSource()==bop[0])
    {
      if(ope){
       d2=Double.parseDouble(str);
       d3=calc(d1,d2,op);
       String dn=Double.toString(d3);
       if(dn.charAt(dn.length()-1)=='0')
        dn=dn.substring(0,dn.length()-1);
       tf.setText(dn);
       ope=false;
       str=dn;
      }
      d1=Double.parseDouble(str);
      opc=true;
      op='+';
    }
    else if(ae.getSource()==bop[1])
    {
      if(ope){
       d2=Double.parseDouble(str);
       d3=calc(d1,d2,op);
       String dn=Double.toString(d3);
       if(dn.charAt(dn.length()-1)=='0')
        dn=dn.substring(0,dn.length()-1);
       tf.setText(dn);
       ope=false;
       str=dn;
      }
      d1=Double.parseDouble(str);
      opc=true;
      op='-';
    }
    else if(ae.getSource()==bop[2])
    {
      if(ope){
       d2=Double.parseDouble(str);
       d3=calc(d1,d2,op);
       String dn=Double.toString(d3);
       if(dn.charAt(dn.length()-1)=='0')
        dn=dn.substring(0,dn.length()-1);
       tf.setText(dn);
       ope=false;
       str=dn;
      }
      d1=Double.parseDouble(str);
      opc=true;
      op='*';
    }
    else if(ae.getSource()==bop[3])
    {
      if(ope){
       d2=Double.parseDouble(str);
       d3=calc(d1,d2,op);
       String dn=Double.toString(d3);
       if(dn.charAt(dn.length()-1)=='0')
        dn=dn.substring(0,dn.length()-1);
       tf.setText(dn);
       ope=false;
       str=dn;
      }
      d1=Double.parseDouble(str);
      opc=true;
      op='/';
    }
    else if(ae.getSource()==bop[4])
    {
      frac=true;
    }
    else if(ae.getSource()==bop[5])
    {
      if(ope)
      {
       d2=Double.parseDouble(str);
       d3=calc(d1,d2,op);
       String dn=Double.toString(d3);
       if(dn.charAt(dn.length()-1)=='0')
        dn=dn.substring(0,dn.length()-1);
       tf.setText(dn);
       d1=d3;
       opc=false;
       ope=false;
      }
    }
    else if(ae.getSource()==bop[6])
    {
      if(ope)
      {
       double temp=Double.parseDouble(tf.getText());
       String tmp=Double.toString(d1*temp/100);
       if(tmp.charAt(tmp.length()-1)=='0')
        tmp=tmp.substring(0,tmp.length()-1);
       tf.setText(tmp);
      }
      else
       tf.setText("0.");
    }
    else if(ae.getSource()==bop[7])
    {
      double temp=Double.parseDouble(tf.getText());
      String tmp=Double.toString(Math.sqrt(temp));
      if(tmp.charAt(tmp.length()-1)=='0')
       tmp=tmp.substring(0,tmp.length()-1);
      tf.setText(tmp);
    }
    else if(ae.getSource()==bop[8])
    {
      double temp=Double.parseDouble(tf.getText());
      String tmp=Double.toString(1/temp);
      if(tmp.equals("Infinity")){
       jl.setText("Cannot divided by zero");
       jd.setSize(150,90);
       jd.setResizable(false);
       jd.setVisible(true);
      }
      else{
      if(tmp.charAt(tmp.length()-1)=='0')
       tmp=tmp.substring(0,tmp.length()-1);
      tf.setText(tmp);
      }
    }
    else if(ae.getSource()==bop[9])
    {
      double temp=Double.parseDouble(tf.getText());
      if(temp!=0){
      String tmp=Double.toString(-1*temp);
      if(tmp.charAt(tmp.length()-1)=='0')
       tmp=tmp.substring(0,tmp.length()-1);
      tf.setText(tmp);
      }else tf.setText("0.");
    }
    else if(ae.getSource()==jdb)
    {
      jd.setVisible(false);
    }
    else
    {
      if(opc){
       tf.setText("0.");
       frac=false;
       str="0";
       ope=true;
       opc=false;
      }
      if(frac)
       tf.setText(str+ae.getActionCommand());
      else{
      if(str.equals("0")){
       tf.setText("");
       tf.setText(ae.getActionCommand()+".");
      }
      else
       tf.setText(str+ae.getActionCommand()+".");
      }
    }
  }
  public double calc(double a,double b,char ch)
  {
    double c=0;
    switch(ch)
    {
      case '+':
       c=a+b;
       break;
      case '-':
       c=a-b;
       break;
      case '*':
       c=a*b;
       break;
      case '/':
       c=a/b;
       break;
    }
    return c;
  }
  public static void main(String[] args) 
  {
    Calculator c=new Calculator("Calculator      ");
    c.setSize(210,250);
    c.setVisible(true);
    Thread t=new Thread(c);
    t.start();
  }
}