Thursday, June 9, 2016

HTML 5 tutorial

Published on Jun 8, 2016
This series of videos demonstrates how to write HTML code that is compliant with the new HTML5 standards. These videos are good for beginners.
This video describes HTML tags, elements, and attributes. The new HTML5 doctype declaration is shown as well as the method for specifying the character encoding for the document. The basic structure of an HTML document is also shown. This video introduces the html, head, meta, title, body, and p tags.
This video describes how to use text. The p tag is demonstrated and the heading tags are introduced. The br tag is also shown. This video also touches on the importance of CSS. A quick demonstration of CSS is shown to center some text and to change its color. In older versions of HTML, text could be centered by using the align attribute. However, this attribute is deprecated and is not valid HTML5. While the align attribute may still work in your browser, it is not compliant with HTML5 standards. Therefore, learning CSS can be very beneficial when working with HTML5 code.
This video demonstrates how to use images and hyperlinks. The difference between relative and absolute addressing is covered. This video shows the height and width attributes used with the img tag. In older versions of HTML, the height and width attributes could be specified in pixels or as a percentage. However, it is not valid HTML5 to specify these values as a percentage. If a percentage value is desired then CSS can be used.
This video introduces 2 elements that are new to HTML5, the audio and video elements. While older browsers don't support these new elements, the popular newer browsers do.

Thursday, June 2, 2016

LUV Calculator JAVA code

import java.io.*;
class Love
{
public static void main(String args[])
{
try
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println(" boy");
String s1=br.readLine();
System.out.println(" girl");
String s2=br.readLine();
int sum=1,sum2=0;
for(int i=0;i<s1.length();i++)
{
char ch=s1.charAt(i);
int ascii=ch;
sum=sum+ascii;
}
for(int i=0;i<s2.length();i++)
{
char ch=s2.charAt(i);
int ascii=ch;
sum2=sum2+ascii;
}
int total=sum+sum2;
int lovepercentage=total%100;
System.out.println("love between "+s1+" and "+s2+" is "+lovepercentage+"%");
}
catch(Exception e)
{
System.out.print("Love calculator exception");
}
}
}

Wednesday, June 1, 2016

Simle Calculator in Java Programming

Code of Simple Calculator in Java Programming




   
    import java.awt.EventQueue;
    import java.awt.GridLayout;
    import java.awt.BorderLayout;
    import java.awt.event.ActionListener;
    import java.awt.event.ActionEvent;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JTextField;
    import javax.swing.JButton;
    import java.awt.Container;
import java.awt.Dimension;

    public class SimpleCalc implements ActionListener{
        
        JFrame guiFrame;
        JPanel buttonPanel;
        JTextField numberCalc;
        int calcOperation = 0;
        int currentCalc;
      
     
        public static void main(String[] args) {
       
           
             EventQueue.invokeLater(new Runnable()
             {
               
                @Override
                 public void run()
                 {
                   
                     new SimpleCalc();       
                 }
             });
                
        }
      
        public SimpleCalc()
        {
            guiFrame = new JFrame();
          
         
            guiFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            guiFrame.setTitle("Simple Calculator");
            guiFrame.setSize(300,300);
        
       
          
          
            numberCalc = new JTextField();
            numberCalc.setPreferredSize(new Dimension(300,50));
            numberCalc.setHorizontalAlignment(JTextField.RIGHT);
          
          
            guiFrame.add(numberCalc, BorderLayout.NORTH);
          
            buttonPanel = new JPanel();
         
            buttonPanel.setLayout(new GridLayout(4,0)); 
            guiFrame.add(buttonPanel, BorderLayout.CENTER);
          
         
            for (int i=1;i<10;i++)
            {
                addButton(buttonPanel, String.valueOf(i));
            }

            JButton addButton = new JButton("+");
            addButton.setActionCommand("+");
          
            OperatorAction subAction = new OperatorAction(1);
            addButton.addActionListener(subAction);
          
            JButton subButton = new JButton("-");
            subButton.setActionCommand("-");
          
            OperatorAction addAction = new OperatorAction(2);
            subButton.addActionListener(addAction);
          
            JButton equalsButton = new JButton("=");
            equalsButton.setActionCommand("=");
            equalsButton.addActionListener(new ActionListener()
            {
                @Override
                public void actionPerformed(ActionEvent event)
                {
                    if (!numberCalc.getText().isEmpty())
                    {
                        int number = Integer.parseInt(numberCalc.getText());
                        if (calcOperation == 1)
                        {
                            int calculate = currentCalc  + number;
                            numberCalc.setText(Integer.toString(calculate));
                        }
                        else if (calcOperation == 2)
                        {
                            int calculate = currentCalc  - number;
                            numberCalc.setText(Integer.toString(calculate));
                        }
                    }
                }
            });
          
            buttonPanel.add(addButton);
            buttonPanel.add(subButton);
            buttonPanel.add(equalsButton);
            guiFrame.setVisible(true);
        }
      
        //All the buttons are following the same pattern
        //so create them all in one place.
        private void addButton(Container parent, String name)
        {
            JButton but = new JButton(name);
            but.setActionCommand(name);
            but.addActionListener(this);
            parent.add(but);
        }
      
     
        public void actionPerformed(ActionEvent event)
        {

            String action = event.getActionCommand();
          
        
            numberCalc.setText(action);     
        }
      
        private class OperatorAction implements ActionListener
        {
            private int operator;
          
            public OperatorAction(int operation)
            {
                operator = operation;
            }
          
            public void actionPerformed(ActionEvent event)
            {
                currentCalc = Integer.parseInt(numberCalc.getText());
                calcOperation = operator;
            }
        }
    }