Walk Lightly on this PLANET and yet leave such a FOOTPRINT that cannot be erased for thousands of Years..!!!
Visit Codstech for Cyber Security related Posts !

Visitors

Thursday, August 30, 2012

CJ-22 : Check user name and password

Type the programs in NOTEPAD or DOS prompt itself, for Consol Application.
Type in NETBEANS or ECLIPSE for Window Application.
Here after , I am just typing the programs only..to know more about it , refer

Introduction to JAVA 

before doing any JAVA Programs.
***********************************************************************************************
import java.io.*;
public class string 
{
    public static void main(String args[])
    {
        String pass,user;
        try
        {
            DataInputStream x=new DataInputStream(System.in);
            System.out.println("Enter user name :");
            user=x.readLine();
            System.out.println("Enter password :");
            pass=x.readLine();
            if(user.equalsIgnoreCase("Priyada")&&pass.equals("java"))
                    {
                        System.out.println("LOGIN");
                    }
                    else
                       {
                              System.out.println("Invalid user name or password"); 
                       }     
        }
     catch(Exception e)
     {
     }
  }
}
=========================================================================
Output : 
Here, I am giving the user name as "Priyada" and password as "java"    .
In this program , only password is case sensitive.
In the output , if we give the correct user name and password, a message will appear as "LOGIN".
Otherwise , "Invalid user name or password"will be displayed.

run:
Enter user name :
priyada
Enter password :
java
LOGIN


==================================================================
Note : 

We can give LOGIN table as shown below : 



The program to draw table like this , will follow soon.....

Wednesday, August 29, 2012

CJ-21 : Program to enter Student Details

Type the programs in NOTEPAD or DOS prompt itself, for Consol Application.
Type in NETBEANS or ECLIPSE for Window Application.
Here after , I am just typing the programs only..to know more about it , refer

Introduction to JAVA 

before doing any JAVA Programs.
***********************************************************************************************
Refer Enter student details using 2 functions also.
***********************************************************************************************
import java.io.*;
public class student 
{
    public static void main(String args[])
    {
        int rno;
        String name,branch;
        try
        {
            DataInputStream x=new DataInputStream(System.in);
            System.out.println("Enter Roll Number :");
            rno=Integer.parseInt(x.readLine());
            System.out.println("Enter Student Name :");
            name=x.readLine();
            System.out.println("Enter Branch :");
            branch=x.readLine();
            System.out.println("==========================");
            System.out.println("Roll Number ="+rno);
            System.out.println("Name ="+name);
            System.out.println("Branch ="+branch);
        }
        catch(Exception e)
        {
        }
        }
 }
=========================================================================
Output : 


Enter Roll Number :
1
Enter Student Name :
Priyada
Enter Branch :
Computer Science
==========================
Roll Number =1
Name =Priyada
Branch =Computer Science


CJ-20 : Matrix addition

Type the programs in NOTEPAD or DOS prompt itself, for Consol Application.
Type in NETBEANS or ECLIPSE for Window Application.
Here after , I am just typing the programs only..to know more about it , refer

Introduction to JAVA 

before doing any JAVA Programs.
***********************************************************************************************
import java.io.*;
public class matrixsum 
{
    public static void main(String args[])throws Exception
    {
        DataInputStream din=new DataInputStream(System.in);
        int twod[][]=new int[10][10];
        int twod1[][]=new int[10][10];
        int sum[][]=new int[10][10];
        int i,j,r,c;
        System.out.println("Enter the number of rows and column of the matrix");
        r=Integer.parseInt(din.readLine());
        c=Integer.parseInt(din.readLine());
        System.out.println("Enter the number of first matrix");
        for(i=0;i<r;i++)
        {
            for(j=0;j<c;j++)
            {
                twod[i][j]=Integer.parseInt(din.readLine());
            }
        }
        System.out.println("The first matrix are :");
        for(i=0;i<r;i++)
        {
            for(j=0;j<c;j++)
            {
                System.out.print(twod[i][j]+" ");
            }
            System.out.println(); 
        }
        System.out.println("Enter the number of second matrix");
        for(i=0;i<r;i++)
        {
            for(j=0;j<c;j++)
            {
                twod1[i][j]=Integer.parseInt(din.readLine());
            }
        }
        System.out.println("The second matrix are :");
        for(i=0;i<r;i++)
        {
            for(j=0;j<c;j++)
            {
                System.out.print(twod1[i][j]+" ");
            }
            System.out.println(); 
        }
        System.out.println("The sum of the matrix are :");
        for(i=0;i<r;i++)
        {
            for(j=0;j<c;j++)
            {
                sum[i][j]=twod[i][j]+twod1[i][j];
                System.out.print(sum[i][j]+" ");
            }
            System.out.println();
        }
    }
}
=========================================================================
Output : 

Enter the number of rows and column of the matrix
2
2
Enter the number of first matrix
2
3
4
5
The first matrix are :
2 3 
4 5 
Enter the number of second matrix
5
4
1
2
The second matrix are :
5 4 
1 2 
The sum of the matrix are :
7 7 
5 7 

Friday, August 17, 2012

CJ-19:Sorting array numbers in ascending order

Type the programs in NOTEPAD or DOS prompt itself, for Consol Application.
Type in NETBEANS or ECLIPSE for Window Application.
Here after , I am just typing the programs only..to know more about it , refer

Introduction to JAVA 

before doing any JAVA Programs.
***********************************************************************************************
import java.io.*;
public class ascending 
{
    public static void main(String args[])throws Exception
    {
        DataInputStream din=new DataInputStream(System.in);
        int t,i,j;
        int n=0;
        int result=0;
        int a[]=new int[10];
        System.out.println("Enter the limit :");
        n=Integer.parseInt(din.readLine());
        System.out.println("Enter the numbers :");
        for(i=0;i<n;i++)
        {
            a[i]=Integer.parseInt(din.readLine());
        }
        for(i=0;i<n;i++)
        {
            for(j=0;j<n;j++)
            {
                if(a[i]<a[j])
                {
                    t=a[i];
                    a[i]=a[j];
                    a[j]=t;
                }
            }
        }
        System.out.println("The numbers in ascending orer is :");
        for(i=0;i<n;i++)
            System.out.println(a[i]);   
    }   
}
=========================================================================
Output : 
Enter the limit :
3
Enter the numbers :
5
7
2
The numbers in ascending order is :
2
5
7



Wednesday, August 15, 2012

CJ-18 : Store n numbers into an Array and print it

Type the programs in NOTEPAD or DOS prompt itself, for Consol Application.
Type in NETBEANS or ECLIPSE for Window Application.
Here after , I am just typing the programs only..to know more about it , refer

Introduction to JAVA 

before doing any JAVA Programs.
***********************************************************************************************
import java.io.*;
public class array 
{
   public static void main(String args[]) 
    {
        int a[]=new int[20];
        int i,n;
        try
        {
            DataInputStream x=new DataInputStream(System.in);
            System.out.println("Enter limit value for array");
            n=Integer.parseInt(x.readLine());
            System.out.println("Enter array elements :");
            for(i=0;i<n;i++)
            {
                a[i]=Integer.parseInt(x.readLine());
            }
            System.out.println("array elements are :");
            for(i=0;i<n;i++)
            {
                System.out.println(a[i]);
            }
        }
        catch(Exception e)
        {
        }
    }      
}    
=========================================================================
Output : 

Enter limit value for array
5
Enter array elements :
1
2
3
4
5
array elements are :
1
2
3
4
5

CJ-17: Program to print a pattern

Type the programs in NOTEPAD or DOS prompt itself, for Consol Application.
Type in NETBEANS or ECLIPSE for Window Application.
Here after , I am just typing the programs only..to know more about it , refer

Introduction to JAVA 

before doing any JAVA Programs.
***********************************************************************************************
Program to print a pattern as shown below :
*
* *
* * *
* * * * 
* * * * * 
***********************************************************************************************
import java.io.*;
public class nestedloop 
{
    public static void main(String args[])
    {
        int i,j;
        for(i=0;i<5;i++)
        {
            for(j=0;j<i;j++)
            {
                System.out.print("*");
                System.out.print("  ");
            }
            System.out.println("");
        }
    }  
}
=========================================================================
Output : 
*
* *
* * *
* * * * 
* * * * * 


CJ-16 : Numbers divisible by 7, and its sum(2)

Type the programs in NOTEPAD or DOS prompt itself, for Consol Application.
Type in NETBEANS or ECLIPSE for Window Application.
Here after , I am just typing the programs only..to know more about it , refer

Introduction to JAVA 

before doing any JAVA Programs.
***********************************************************************************************

import java.io.*;

public class div1
{
    public static void main(String args[])
    {
        int sum=0,ct=0,n,i;
        try
        {
            DataInputStream s= new DataInputStream(System.in);
            System.out.println("Enter the limit :");
            n=Integer.parseInt(s.readLine());
            System.out.println("Numbers divisible by 7 are :");
            for(i=0;i<n;i++)
            {
                if(i%7==0)
                {
                    System.out.println(i);
                    ct++;
                    sum=sum+i;
                }
            }
            System.out.println("Sum= "+sum);
            System.out.println("Total Numbers divisible by 7 is :"+ct);
        }
        catch(Exception e)
        {
        }
    }
}
=========================================================================
Output :


Enter the limit :
50
Numbers divisible by 7 are :
0
7
14
21
28
35
42
49
Sum= 196
Total Numbers divisible by 7 is :8


Monday, August 6, 2012

CJ-15:Numbers divisible by 7, and its sum(1)

Type the programs in NOTEPAD or DOS prompt itself, for Consol Application.
Type in NETBEANS or ECLIPSE for Window Application.
Here after , I am just typing the programs only..to know more about it , refer

Introduction to JAVA 

before doing any JAVA Programs.
***********************************************************************************************

import java.io.*;
class div
{
public static void main(String args[])
{
   int sum=0,ct=0,n,i=0;
   try
   {
DataInputStream s=new DataInputStream(System.in);
System.out.println("Enter Limit :");
n=Integer.parseInt(s.readLine());
System.out.println("Numbers divisible by 7 are :");
do
{
   if(i%7==0)
   {
System.out.println(i);
ct++;
sum=sum+i;
   }
   i++;
}
while(i<=n);
System.out.println("Sum = "+sum);
System.out.println("Total Numbers divisible by 7 is : "+ct);
    }
    catch(Exception e)
    {
    }
}
}   
=========================================================================
Output :
Enter Limit:
50
Numbers divisible by 7 are :
0
7
14
21
28
35
42
49
Sum = 196
Total Numbers divisible by 7 is : 8