Wednesday, June 7, 2017

Greatest of Five Numbers

Following Program will find the Greatest Number Out of Five Numbers and Consider Equality also:

Code:

public class NT {

public static void main(String[] nt)
{
int a=76,b=23,c=75,d=67,e=76;
if(a>b)
{
if(a>c)
{
if(a>d)
{
if(a>e)
{
System.out.println("A is Greatest");
}
else if(a==e)
{
System.out.println("A,E are Greatest and Equal");
}
else
{
System.out.println("E is Greatest");
}
}
else if(a==d)
{
if(a>e)
{
System.out.println("A,D are Greatest and Equal");
}
else if(a==e)
{
System.out.println("A,D,E are Greatest and Equal");
}
else
{
System.out.println("E is Greatest");
}  
}
else
{
if(d>e)
{
System.out.println("D is Greatest ");
}
else if(d==e)
{
System.out.println("D,E are Greatest and Equal");
}
else
{
System.out.println("E is Greatest");
}
}

}
else if(a==c)
{
if(a>d)
{
if(a>e)
{
System.out.println("A,C are Greatest and Equal");
}
else if(a==e)
{
System.out.println("A,C,E are Greatest and Equal");
}
else
{
System.out.println("E is Greatest");
}
}
else if(a==d)
{
if(a>e)
{
System.out.println("A,C,D are Greatest and Equal");
}
else if(a==e)
{
System.out.println("A,C,D,E are Greatest and Equal");
}
else
{
System.out.println("E is Greatest");
}  
}
else
{
if(d>e)
{
System.out.println("D is Greatest ");
}
else if(d==e)
{
System.out.println("D,E are Greatest and Equal");
}
else
{
System.out.println("e is greatest");
}
}
}
else
{
if(c>d)
{
if(c>e)
{
System.out.println("C is Greatest");
}
else if(c==e)
{
System.out.println("C,E are Greatest and Equal");
}
else
{
System.out.println("E is Greatest");
}
}
else if(c==d)
{
if(c>e)
{
System.out.println("C,D are Greatest and Equal");
}
else if(c==e)
{
System.out.println("C,D,E are Greatest and Equal");
}
else
{
System.out.println("E is Greatest");
}  
}
else
{
if(d>e)
{
System.out.println("D is Greatest ");
}
else if(d==e)
{
System.out.println("D,E is Greatest and Equal");
}
else
{
System.out.println("E is Greatest");
}
}
}
}

else if(a==b)
{
if(a>c)
{
if(a>d)
{
if(a>e)
{
System.out.println("A,B are Greatest and Equal");
}
else if(a==e)
{
System.out.println("A,B,E is Greatest and Equal");
}
else
{
System.out.println("E is Greatest");
}
}
else if(a==d)
{
if(a>e)
{
System.out.println("A,B,D is Greatest and Equal");
}
else if(a==e)
{
System.out.println("A,B,D,E are Greatest and Equal");
}
else
{
System.out.println("E is Greatest");
}  
}
else
{
if(d>e)
{
System.out.println("D is Greatest ");
}
else if(d==e)
{
System.out.println("D,E are Greatest and Equal");
}
else
{
System.out.println("E is Greatest");
}
}

}
else if(a==c)
{
if(a>d)
{
if(a>e)
{
System.out.println("A,B,C are Greatest and Equal");
}
else if(a==e)
{
System.out.println("A,B,C,E are Greatest and Equal");
}
else
{
System.out.println("E is Greatest");
}
}
else if(a==d)
{
if(a>e)
{
System.out.println("A,B,C,D are Greatest and Equal");
}
else if(a==e)
{
System.out.println("A,B,C,D,E are Greatest and Equal");
}
else
{
System.out.println("E is Greatest");
}  
}
else
{
if(d>e)
{
System.out.println("D is Greatest ");
}
else if(d==e)
{
System.out.println("D,E are Greatest and Equal");
}
else
{
System.out.println("E is Greatest");
}
}
}
else
{
if(c>d)
{
if(c>e)
{
System.out.println("C is Greatest");
}
else if(c==e)
{
System.out.println("C,E are Greatest and Equal");
}
else
{
System.out.println("E is Greatest");
}
}
else if(c==d)
{
if(c>e)
{
System.out.println("C,D are Greatest and Equal");
}
else if(c==e)
{
System.out.println("C,D,E are Greatest and Equal");
}
else
{
System.out.println("E is Greatest");
}  
}
else
{
if(d>e)
{
System.out.println("D is Greatest ");
}
else if(d==e)
{
System.out.println("D,E are Greatest and Equal");
}
else
{
System.out.println("E is Greatest");
}
}
}
}
else
{
if(b>c)
{
if(b>d)
{
if(b>e)
{
System.out.println("B is Greatest");
}
else if(b==e)
{
System.out.println("B,E are Greatest and Equal");
}
else
{
System.out.println("E is Greatest");
}
}
else if(b==d)
{
if(b>e)
{
System.out.println("B,D are Greatest and Equal");
}
else if(b==e)
{
System.out.println("B,D,E are Greatest and Equal");
}
else
{
System.out.println("E is Greatest");
}  
}
else
{
if(d>e)
{
System.out.println("D is Greatest ");
}
else if(d==e)
{
System.out.println("D,E are Greatest and Equal");
}
else
{
System.out.println("E is Greatest");
}
}

}
else if(b==c)
{
if(b>d)
{
if(b>e)
{
System.out.println("B,C are Greatest and Equal");
}
else if(b==e)
{
System.out.println("B,C,E are Greatest and Equal");
}
else
{
System.out.println("E is Greatest");
}
}
else if(b==d)
{
if(b>e)
{
System.out.println("B,C,D are Greatest and Equal");
}
else if(b==e)
{
System.out.println("B,C,D,E are Greatest and Equal");
}
else
{
System.out.println("E is Greatest");
}  
}
else
{
if(d>e)
{
System.out.println("D is Greatest ");
}
else if(d==e)
{
System.out.println("D,E are Greatest and Equal");
}
else
{
System.out.println("E is Greatest");
}
}
}
else
{
if(c>d)
{
if(c>e)
{
System.out.println("C is Greatest");
}
else if(c==e)
{
System.out.println("C,E are Greatest and Equal");
}
else
{
System.out.println("E is Greatest");
}
}
else if(c==d)
{
if(c>e)
{
System.out.println("C,D is Greatest and Equal");
}
else if(c==e)
{
System.out.println("C,D,E are Greatest and Equal");
}
else
{
System.out.println("E is Greatest");
}  
}
else
{
if(d>e)
{
System.out.println("D is Greatest ");
}
else if(d==e)
{
System.out.println("D,E are Greatest and Equal");
}
else
{
System.out.println("E is Greatest");
}
}
}
}
}
}

Output:


IT'S SIMPLEST APPROACH IS Click Here

Saturday, April 29, 2017

Registration Form Java

Code:

import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import javax.swing.*;
public class Formm extends Frame
{   Label [] l=new Label[8];
    TextField[] t=new TextField[6];
    TextArea a=new TextArea();
    CheckboxGroup p=new CheckboxGroup();
    Checkbox c1=new Checkbox("Male",p,true);
    Checkbox c2=new Checkbox("Female",p,false);
    Button s=new Button("Submit");
    Button r=new Button("Reset");
    int y=30;
    Connection cp;
    Statement st;
    Formm()
    {
        setLayout(null);
        setVisible(true);
        for(int i=0;i<8;i++)
        {
            l[i]=new Label();
            l[i].setBounds(30,y,100,30);
            add(l[i]);
            y+=40;
        }
        y=30;
        for(int i=0;i<6;i++)
        {
            t[i]=new TextField();
            t[i].setBounds(130,y,100,30);
            add(t[i]);
            y+=40;
        }
        a.setBounds(130,310,150,80);
        add(a);
        s.setBounds(50,400,50,30);
        add(s);
        r.setBounds(120,400,50,30);
        add(r);
        c1.setBounds(130,270,50,30);
        add(c1);
        c2.setBounds(180,270,60,30);
        add(c2);
        l[0].setText("Name");
        l[1].setText("Email");
        l[2].setText("Password");
        l[3].setText("Pincode");
        l[4].setText("DOB");
        l[5].setText("Mobile Number");
        l[6].setText("Gender");
        l[7].setText("Address");
        Label h=new Label("City:");
        h.setBounds(300,310,50,20);
        add(h);
        Choice c=new Choice();
        c.setBounds(350,310,100,30);
        c.add("Ludhiana");
        c.add("Jalandhar");
        c.add("Bhatinda");
        c.add("Amritsar");
        c.add("Hoshiarpur");
        add(c);
        this.addWindowListener(new WindowAdapter(){
            public void windowClosing(WindowEvent e)
            {
                System.exit(0);
            }
        });
        try
        {
         
            Class.forName("com.mysql.jdbc.Driver");
            cp=DriverManager.getConnection("jdbc:mysql://localhost/college","root","password");
            st=cp.createStatement();
        }
        catch(Exception e)
        {
            System.out.println("Error"+e);
        }
        r.addActionListener(new ActionListener()
        {
            public void actionPerformed(ActionEvent e)
            {
                for(int i=0;i<6;i++)
                {
                    t[i].setText(" ");
                }
                a.setText(" ");
            }
        });
        s.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent e)
            {
           
             try
        {
            st.executeUpdate("Insert into form values('"+t[0].getText()+"','"+t[1].getText()+"','"+t[2].getText()+"','"+t[3].getText()+"','"+t[4].getText()+"','"+a.getText()+"','"+t[5].getText()+"','"+p.getSelectedCheckbox().getLabel()+"','"+c.getSelectedItem()+",) ");
        }
        catch(Exception ex)
        {
            System.out.println("Error Occured"+ex);
        }
             JOptionPane.showMessageDialog(null,"Record Entered");
             for(int i=0;i<6;i++)
             {
                 t[i].setText("");
             }
             a.setText("");
            }
        });
        setSize(500,500);  
    }
    public static void main(String[] nt)
    {
        new Formm();
    }
}

Output::





Friday, April 21, 2017

Anagram Python

Code::

def isanagram(s1,s2):
    s1="".join(sorted(s1))
    s2="".join(sorted(s2))
    if s1==s2:
        print("Anagram")
    else:
        print("Not Anagram")
     
     
w1=input("Enter First Word: ")
w2=input("Enter Second Word: ")
isanagram(w1.lower(),w2.lower())


Output:

Tuesday, April 18, 2017

TCP /IP,Ping/Ipconfig,File Sharing

Screenshots:








Ubuntu Installation and Virtual Box

Steps:

1.



























Tuesday, April 11, 2017

Currency Converter Java

Code::

import javax.swing.*;
import java.awt.event.*;
public class CurrencyConverter extends JFrame
{    JTextField t1=new JTextField();
     JTextField t2=new JTextField();
     JTextField t3=new JTextField();
     JLabel l1=new JLabel("Rupees:");
     JLabel l2=new JLabel("US Dollars:");
     JLabel l3=new JLabel("Euros:");
     CurrencyConverter()
     {
        setLayout(null);
        setTitle("Converter");
        setVisible(true);
        setSize(400,200);
        l1.setBounds(20,30,70,30);
        l2.setBounds(20,70,70,30);
        l3.setBounds(20,110,70,30);
        t1.setBounds(120,30,70,30);
        t2.setBounds(120,70,70,30);
        t3.setBounds(120,110,70,30);
        add(t1);
        add(l1);
        add(l2);
        add(t2);
        add(t3);
        add(l3);
        t1.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent e)
            {
                double a=Double.parseDouble(t1.getText());
                t2.setText(String.format("%.2f",a*0.015));
                t3.setText(String.format("%.2f",a*0.015));
                
            }
        });
        t2.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent e)
            {
                double a=Double.parseDouble(t2.getText());
                t1.setText(String.format("%.2f",a*64.68));
                t3.setText(String.format("%.2f",a*0.94));
                
            }
        });
        t3.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent e)
            {
                double a=Double.parseDouble(t3.getText());
                t2.setText(String.format("%.2f",a*1.06));
                t1.setText(String.format("%.2f",a*68.71));
                
            }
        });
     }
      public static void main(String[] nt) 
    {
        new CurrencyConverter();
    }
    
}

Output::


Temperature Converter Java

Code::

import javax.swing.*;
import java.awt.event.*;
public class Converter extends JFrame 
{
    
    JTextField t1 =new JTextField();
    JTextField t2 =new JTextField();
    JLabel l1=new JLabel("Celsius:");
    JLabel l2=new JLabel("Fahrenheit:");
    Converter()
    {
        setLayout(null);
        setTitle("Converter");
        setVisible(true);
        setSize(400,200);
        l1.setBounds(20,30,70,30);
        l2.setBounds(20,70,70,30);
        t1.setBounds(120,30,70,30);
        t2.setBounds(120,70,70,30);
        add(t1);
        add(l1);
        add(l2);
        add(t2);
        t1.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent e)
            {  double a=(Double.parseDouble(t1.getText()))*1.8+32;
                t2.setText(String.format("%.1f",a));
            }
        });
        t2.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent e)
            {  double a=(((Double.parseDouble(t2.getText()))-32)/1.8);
                t1.setText(String.format("%.1f",a));
            }
        });
    }
   
    public static void main(String[] nt) {
      new Converter();
    }
    
}

Output::