Honhar Engineer

Honhar Engineer
Thanks for visiting,stay connected for more updates !

Tuesday, August 13, 2013

First Come First Serve(FCFS) Scheduling Algorithm

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int y,b[10];
char n[10];
int w[10];
int t[10];
w[1]=0;
cout<<"Enter no. processes:";
cin>>y;
for(int i=0;i<y;i++)
{
cout<<"Enter process name:";
cin>>n[i];
cout<<"Enter burst time:";
cin>>b[i];
}
cout<<"Waiting time for p1="<<w[1]<<endl;
for(int k=2;k<=y;k++)
{
w[k]=w[k-1]+b[k-2];
cout<<endl<<"Waiting time for p"<<k<<"="<<w[k]<<endl;
}
for(int j=1;j<4;j++)
{
t[j]=w[j]+b[j-1];
cout<<endl<<"Turn around time for p" <<j<<"="<<t[j]<<endl;
}
getch();
}

Monday, August 12, 2013

Java program for understanding Mouse Listeners

import java.awt.EventQueue;
import java.awt.BorderLayout;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import java.awt.Color;
import javax.swing.BorderFactory;
import javax.swing.border.Border;
import java.awt.event.MouseListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseWheelListener;
import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseMotionListener;

public class MouseLabel {

    JLabel mouseLabel;
    JLabel mouseMoveLabel;
    JTextArea mouseEvents;
   
    //Note: Typically the main method will be in a
    //separate class. As this is a simple one class
    //example it's all in the one class.
    public static void main(String[] args) {
    
         //Use the event dispatch thread for Swing components
         EventQueue.invokeLater(new Runnable()
         {
            
            @Override
             public void run()
             {
                
                 new MouseLabel();        
             }
         });
             
    }
   
    public MouseLabel()
    {
        JFrame guiFrame = new JFrame();
       
        //make sure the program exits when the frame closes
        guiFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        guiFrame.setTitle("Mouse Event Example");
        guiFrame.setSize(700,300);
     
        //This will center the JFrame in the middle of the screen
        guiFrame.setLocationRelativeTo(null);
       
        //creating a border to highlight the label areas
        Border outline = BorderFactory.createLineBorder(Color.black);
       
        //mouseLabel will trigger the Mouse click evetns
        mouseLabel = new JLabel("Interactive Label", JLabel.CENTER);
        mouseLabel.setBorder(outline);
       
        //Attach the MouseListener to mouseLabel
        //as an anonymous inner class.
        //Each method changes the test of mouseLabel and
        //logs the mouse event in the JTextArea
        mouseLabel.addMouseListener(new MouseListener()
        {
           
            @Override
            public void mouseClicked(MouseEvent e)
            {
               
                mouseLabel.setText("I've been clicked!");
                mouseEvents.append("MouseClicked Event");
                mouseEvents.append(e.getClickCount() + " click(s)\n");
                mouseEvents.append("Xpos: " + e.getX() + " Ypos: " + e.getY() + "\n");
               
            }
            @Override
            public void mousePressed(MouseEvent e)
            {
               
                mouseLabel.setText("You're holding the mouse button aren't you?");
                mouseEvents.append("MousePressed Event\n");
            }
           
            @Override
            public void mouseExited(MouseEvent e)
            {
                mouseLabel.setText("The mouse has run away!");
                mouseEvents.append("MouseExited Event\n");
            }
           
            @Override
            public void mouseEntered(MouseEvent e)
            {
               
                mouseLabel.setText("I can feel the presence of the Mouse");
                mouseEvents.append("MouseEntered Event\n");
            }
           
            @Override
            public void mouseReleased(MouseEvent e)
            {
               
                mouseLabel.setText("You've let go of the mouse button");
                mouseEvents.append("MouseReleased Event\n");
            }
           
        });
       
        //mouseMoveLabel triggers the mouse motion events
        mouseMoveLabel = new JLabel("Drag the Mouse!");
        mouseMoveLabel.setBorder(outline);
       
        //Attach the MouseMotionListener to mouseMoveLabel
        //as an anonymous inner class.
        //Each method logs the events triggered in the JTextArea
        mouseMoveLabel.addMouseMotionListener(new MouseMotionListener(){
            @Override
            public void mouseDragged(MouseEvent e)
            {          
                mouseEvents.append("MouseDragged Event\n");
            }

            @Override
            public void mouseMoved(MouseEvent e)
            {
                mouseEvents.append("MouseMoved Event\n");
               
            }
       
        });
       
       
        mouseEvents = new JTextArea("The Mouse events can be seen here:\n");
       
        //Place the JTextArea into a JScrollPane to be able to scroll
        //through all the events logged. It's also perfect for listening
        //for MouseWheelListener events
        JScrollPane textScroll = new JScrollPane(mouseEvents);
       
        //Attach the MouseWheelListener to textScroll
        //as an anonymous inner class.
        //As some many events are fired by the mouse moving the method
        //just changes the text of mouseLabel rather than logging them
        //all in the JTextArea.
        textScroll.addMouseWheelListener(new MouseWheelListener(){
       
            @Override
            public void mouseWheelMoved(MouseWheelEvent e)
            {
                mouseLabel.setText("You've moved the mouse wheel");
            }
       
        });
       
        guiFrame.add(mouseMoveLabel, BorderLayout.WEST);
        guiFrame.add(mouseLabel, BorderLayout.CENTER);
        guiFrame.add(textScroll, BorderLayout.EAST);
        guiFrame.setVisible(true);
    }
    }

Sunday, August 11, 2013

Get IP Address using Java code

import java.util.*;
import java.lang.*;
import java.net.*;  
public class GetOwnIP
{
public static void main(String args[])
{
try
{
InetAddress ownIP=InetAddress.getLocalHost();
System.out.println("IP of my system is := "+ownIP.getHostAddress());
}
catch (Exception e)
{
System.out.println("Exception caught ="+e.getMessage());
}
}
}

Round-Robin Scheduling Algorithm

#include<stdio.h>
#include<conio.h>
#include<process.h>
#include<string.h>
void main()
{
char p[10][5];
int et[10],wt[10],timer,count,pt[10],rt,i,j,totwt=0,t,n=3,found=0,m;
float avgwt;
clrscr();
for(i=0;i<n;i++)
{
printf("enter the process name : ");
scanf("%s",&p[i]);
printf("enter the processing time : ");
scanf("%d",&pt[i]);
}
printf("enter the time quantum : ");
scanf("%d",&timer);
m=n;
wt[0]=0;
i=0;
do
{
if(pt[i]>timer)
{
rt=pt[i]-timer;
strcpy(p[n],p[i]);
pt[n]=rt;
et[i]=timer;
n++;
}
else
{
et[i]=pt[i];
}
i++;
wt[i]=wt[i-1]+et[i-1];
}
while(i<n);
count=0;
for(i=0;i<m;i++)
{
for(j=i+1;j<=n;j++)
{
if(strcmp(p[i],p[j])==0)
{
count++;
found=j;
}
}
if(found!=0)
{
 wt[i]=wt[found]-(count*timer);
count=0; found=0;
}
}
for(i=0;i<m;i++)
{
totwt+=wt[i];
}
avgwt=(float)totwt/m;
for(i=0;i<m;i++)
{
printf("\n%s\t%d\t%d",p[i],pt[i],wt[i]);
}
printf("\ntotal waiting time %d\n",totwt);
printf("total avgtime %f",avgwt);
getch();
}

Saturday, August 10, 2013

Top 5 Countries with world’s fastest internet

1. Hong kong
Speed: 63.9 Mbps
It has the worlds fastest internet speed. It has blazing fast internet, an average peak speed of 63.6 Mbp megabits per seconds. At this speed you can download HD movie in about 2 minutes.

2 Japan
Speed: 50 Mbps
The home of Nintendo and Sony had the second fastest internet speed, thanks to the high-speed fibre optics that run through many parts of the island nation. Japan’s average peak broadband speed reached an impressive 50 Mbps, which was more than 170% faster than the global average

3 . Romania
Speed: 47.9 Mbps
When last checked in on Romania,it was ranked No. 5 and was the only country to see its average fall from the previous quarter. The country is now back on track, andhas elevated itself with an averagepeak speed of 47.9 Mbps. That’s 160% faster than the global average. Romania’s average was 9% higher than the previous quarter

4. South Korea
Speed: 44.8 Mbps
Serious PC gamers who want to dominate in StarCraftneed fast, low latency internet connections. They’ll find that in South Korea, home to consumerelectronics giants Samsung and LG. The country’s average peak hit 44.8 Mbps, about 143% faster than theglobal average. It was the only region to lose speed compared with a year ago,

5. Latvia
Speed: 44.2 Mbps
Smaller countries are easier to blanket with high-speed internet, which is one of the reasons why Latvia consistently ranks high on this list. The average peak broadband speed was 44.2 Mbps, about 140% faster than the globalaverage

INTERNET ERROR CODES

Error 400 - Bad request.
Error 401 -unauthorized request.
Error 403 - forbidden.
Error 404 - Not found.
Error 500 -Internal error.
Error 501 - Not Implemented
Error 502 - Bad Gateway
Error 503 -Service unavailable.
Error 504 - Gateway Time-Out.
Error 505 - HTTP Version not supported/DNS Lookup Fail/ unknown host.
Error 500-599 - Server Errors.

List Of Full Form of Domain Names Extensions

.com → commercial Internet sites.
.edu → educational sites .
.firm → for an Internet site for a business.
.gov → for a U.S. government site on the Internet.
.int → international institutions.
.mil → for a U.S. military site on the Internet.
.mobi → for mobile phones.
.nato → for NATO sites.
.net → for Internet administrative sites.
.nom → for a personal site on the Internet.
.org → for organizational Internet sites.
.store →for a retail business.
.web → for an Internet site that is about the World Wide Web.
.Us → united states 

.uk united kindom
 

In 1998 - We have 8 extensions
In 2004 - We have 23 extensions
In 2013 - It will be 700+ new domain extensions released to the public.