Thursday, 27 March 2014

Arithmetic Mean In Excel

Arithmetic Mean is calculating of mean of the series of numbers.You have to add all the numbers and then divide the obtained sum by the total no.of the given series.
It is very common to measure the central tendency in Excel.

OR simply get the average of the series that is find out the average through AVERAGE function.
Through AVERAGE FUNCTION:


Through SUM FUNCTION:

To get more detail about Excel functions: Refer to Excel Categories.


Tuesday, 18 March 2014

Mouse handling

This program tells about how to use action Listener methods and its methods along with how to handle the mouse events.whenever you perform such type of functions such as :click,released,drag,move,enter or exit from the window then it reflects your output as by the repaint method:

To Know more about the mouse event functions and its calculations check out the Java Label:

NewClass.java:

import java.awt.event.*;
import java.applet.*;
import java.awt.*;
/*
<applet code="NewClass" width=300 height=100>
</applet>
*/

public class NewClass extends Applet implements MouseListener, MouseMotionListener
{
    String msg=" ";
    int mouseX=0,mouseY=0;
    public void init()
    {
        addMouseListener(this);
        addMouseMotionListener(this);
       
    }
    public void mouseClicked(MouseEvent me)
    {
        mouseX= 0;
        mouseY=10;
        msg="mouse clicked at:"+me.getX()+" ' "+me.getY();
        repaint();
       
    }
    public void mouseEntered(MouseEvent me)
    {
        mouseX=0;
        mouseY=10;
        msg="mouse entered";
        repaint();
       
    }
    public void mouseExited(MouseEvent me)
    { mouseX=0;
        mouseY=10;
        msg="mouse Exited";
        repaint();
       
    }
    public void mousePressed(MouseEvent me)
    {
         mouseX=me.getX();
        mouseY=me.getY();
        msg="Mouse Pressed";
        repaint();
    }
    public void mouseReleased(MouseEvent me)
    {
         mouseX=0;
        mouseY=10;
        msg="mouse Realeased";
        repaint();
    }
    public void mouseDragged(MouseEvent me)
    {
         mouseX=me.getX();
        mouseY=me.getY();
        msg="***";
        showStatus("Dragging mouse at "+ mouseX +" ,"+ mouseY);
        repaint();
    }
    public void mouseMoved(MouseEvent me)
    {
         showStatus("moving mouse at"+ me.getX() + ","+ me.getY());
    }
    public void paint(Graphics g)
    {
        g.drawString(msg,mouseX,mouseY);
    }
}

output:







Optimal Page Replacement C program

OPTIMAL PAGE REPLACEMENT ALGORITHM

Program Description: Optimal Page Replacement refers to the removal of the page that will not be used in the future, for the longest period of time.

Program Code:

#include<stdio.h>
int main()
{
int n,pg[30],fr[10];
int count[10],i,j,k,fault,f,flag,temp,current,c,dist,max,m,cnt,p,x;
fault=0;
dist=0;
k=0;
printf("Enter the total no pages:\t");
scanf("%d",&n);
printf("Enter the sequence:");
for(i=0;i<n;i++)
scanf("%d",&pg[i]);
printf("\nEnter frame size:");
scanf("%d",&f);

for(i=0;i<f;i++)
{
count[i]=0;
fr[i]=-1;
}
for(i=0;i<n;i++)
{
flag=0;
temp=pg[i];
for(j=0;j<f;j++)
{
if(temp==fr[j])
{
flag=1;
break;
}
}
if((flag==0)&&(k<f))
{
fault++;
fr[k]=temp;
k++;
}
else if((flag==0)&&(k==f))
{
fault++;
for(cnt=0;cnt<f;cnt++)
{
current=fr[cnt];
for(c=i;c<n;c++)
{
if(current!=pg[c])
count[cnt]++;
else
break;
}
}
max=0;
for(m=0;m<f;m++)
{
if(count[m]>max)
{
max=count[m];
p=m;
}
}
fr[p]=temp;
}
printf("\npage  %d  frame\t",pg[i]);
for(x=0;x<f;x++)
{
printf("%d\t",fr[x]);
}
}
printf("\nTotal number of faults=%d",fault);
return 0;
}

Output:

Java First Applet Program

This given program demonstrate how the Applet works.How the Function get performed?
To run applet Program First we need to initialize the variables,befor that extends the applet class.

First.java:(Created in NET BEANS IDE )
import java.applet.*;
import java.awt.*;

public class First extends Applet
{
    public void init()
    {
       
    }
    public void start()
    {
       
    }
    public void stop()
    {
       
    }
    public void destroy()
    {
       
    }
    public void paint(Graphics g)
    {
        showStatus("applet Started");
    }
 }

To run this program:
$javac First.java
$appletviewer First

OutPut:
 
To get more details follow Java Label....

Applet StartUP

To use Applet in java program or execution can done by only two ways, Before that, Applet are not Stand-alone program.they run either a web browser or an applet viewer provided by JDK (Java Development Kit).

Applet Program does not begin with main() function.It has its own functions such as:
1.void init( ) 
2.Void start( )
3. void stop( )
4. void showStatus( )
5. void destroy( )
6. void paint(Graphics g) defined in AWT component class, where applet will override it.

In Contrast, Swing Applet has different mechanism to execute their program.

To get more details more about java functions : Refer Java Category 


Java Applet

Applet provides more compatibility with Graphical User Interface. You can Add-on more features such as buttons,menu-bars,frames, can be useful to develop different application like games, any software etc.

There are two types of applet in java:
1.Simple applet based on Applet Class ,use the abstract window toolkit(AWT) to provide the graphical user interface.

2. Swing Class Applet "JApplet". It provides the same features as we used in AWT along with some richer function and additional functionality to the AWT function and more compatible with graphics functions.
JApplet inherits Applet .


HTML APPLET Tag

Applet can run on the browser window through <applet> tag and you can get the output as you get in your appletviewer.
The one restriction with appletviewer is it executes only one java program at one time,In Contrast, browser can consists of more than one applet Contains.Let's have a look at how to enroll the applet tag in browser window.
Applet tag with their some alternatives:
<applet
code="name_of_java_class_name"
width=pixels
height=pixels
align=alignment
vspace=vertical_space_pixels
hspace=horizontal_space_pixels

</applet>

To get details about the attributes of applet tag : click on Java Label.


Tuesday, 11 March 2014

HTML and JavaScript

HTML and JavaScript works together.JavaScript is a Scripting language. That is, the code is not
compiled but instead it appears as ASCII text in an HTMLfile.

JavaScript is used,when you have Scenario such as you have created a website in which you want to give many options to the users and if user chose any option out of them then what action to be performed at that instant, That's where JavaScript matters.

For integrating it into the HTML code, you have three possibilities:

1. Inclusion in header part:

    ==> Incapacitate into header part:   


<html>

<head>

<title>

My Page

</title>

<script language="javascript">

/*

write your code here

functions and methods

*/

</script>

The Tag <script language="JavaScript"> introduces the JavaScript source code, the tag
</script> ends it.

For Second incorporation of JavaScript into html code ,Click Here 

For Further details about JavaScript go to "JavaScript" Label.


First Java Script Program

This is first JavaScript program."alert( )" function used to pop-up the some message.It will display the content written before the script programming than the script will be available with pop-up box.

Program:


<html>
<head>
<title> MY first Javascript Page </title>
</head>
<body>
<h3>
My first javaScript Page
</h3>
<script>
alert("Hello My Page");
</script>
My Second-Half of JavaScript Page
<script>
alert("Hello my Second Half");
</script>
</body>
</html>

Output will Display Like this on Your Browser:




 










Look At the other Programs in JavaScript Label. 

HTML and JavaScript Incorporation

In First Incorporation we have how to include JavaScript in HTML header part.

For Second Possibilities of inclusion of JavaScript in Html Code is you code part.It's just depend on your code to carry out any functionality or any reaction,change in something like to over the mouse of any particular thing then what action has been specified.

In this,When the Web Page loads there is a pop-up alert open and give some reaction tell us something through display message.

<body onload="hello()">
Hello function is to be performed whenever page loads.


For Complete program refer this Link:  Incorporation Program

Third Incorporation of HTML and Java.

Further Fuctionality and programs of JavaScript and HTML refer Divisions.