Wednesday, May 30, 2012 0 comments

Day 17,30 May 2012



Today we were taught about the Event handling in JAVA .We were taught about the concept of Keylistener and Mouselistener in java. Key events indicate when the user is typing at the keyboard. Specifically, key events are fired by the component with the keyboard focus when the user presses or releases keyboard keys.
Notifications are sent about two basic kinds of key events:
The typing of a Unicode character
The pressing or releasing of a key on the keyboard
The first kind of event is called a key-typed event. The second kind is either a key-pressed or key-released event.
Keylistener listens to an event related to key pressed & release events and user can apply an action that would happen if that key events happens.e.g copy ,cut, paste shortcuts.
Mouse events notify when the user uses the mouse (or similar input device) to interact with a component. Mouse events occur when the cursor enters or exits a component's onscreen area and when the user presses or releases one of the mouse buttons.
Mouselistner listens to an event such mousemotion, mouseclick etc and  user can apply an action that would happen if that mouse events happens.
Tuesday, May 29, 2012 0 comments

Day 16 :Date 29 May 2012



Today we were taught about the applets in Java.Applet is java program that can be embedded into HTML pages. Java applets runs on the java enables web browsers such as mozila and internet explorer. Applet is designed to run remotely on the client browser, so there are some restrictions on it. Applet can’t access system resources on the local computer. Applets are used to make the web site more dynamic and entertaining.
Advantages of Applet:
Applets are cross platform and can run on Windows, Mac OS and Linux platform
Applets can work all the version of Java Plugin
Applets runs in a sandbox, so the user does not need to trust the code, so it can work without security approval
Applets are supported by most web browsers
Applets are cached in most web browsers, so will be quick to load when returning to a web page
User can also have full access to the machine if user allows
import java.awt.*;
import  java.applet.*;
public class app extends Applet{
public void init()
{
Font f= new Font(“Monotype”,1,12);
SetFont(f);
}
public void paint(Graphics g)
{
g.drawLine (x1,y1,x2,y2);
g.setcolor(Color.RED);
g.fillRect;
g.drawString;
}
Monday, May 28, 2012 0 comments

Day 15 :Date 28 May 2012



Today we were taught about the concept of Exception Handling.An exception is a problem that arises during the execution of a program. An exception can occur for many different reasons, including the following:
A user has entered invalid data.
A file that needs to be opened cannot be found.
A network connection has been lost in the middle of communications, or the JVM has run out of memory.
Some of these exceptions are caused by user error, others by programmer error, and others by physical resources that have failed in some manner.
To understand how exception handling works in Java, you need to understand the three categories of exceptions:
Checked exceptions: A checked exception is an exception that is typically a user error or a problem that cannot be foreseen by the programmer. For example, if a file is to be opened, but the file cannot be found, an exception occurs. These exceptions cannot simply be ignored at the time of compilation.
Runtime exceptions: A runtime exception is an exception that occurs that probably could have been avoided by the programmer. As opposed to checked exceptions, runtime exceptions are ignored at the time of compliation.
Errors: These are not exceptions at all, but problems that arise beyond the control of the user or the programmer. Errors are typically ignored in your code because you can rarely do anything about an error. For example, if a stack overflow occurs, an error will arise. They are also ignored at the time of compilation.
try{
a = JOptionPane.ShowInputDialog(“Enter the value”);
System.out.print(“Value of a is “+a);
}
catch(Exception ex)
{
System.out.print(ex,getMessage());
}
Sunday, May 27, 2012 0 comments

Day 14 : 27 May 2012



Today we revised the work we have done in this week.
Saturday, May 26, 2012 0 comments

Day 13 :Date 26,2012



Today we were Taught about the Interfaces In JAva. An interface in the Java programming language is an abstract type that is used to specify an interface (in the generic sense of the term) that classes must implement. Interfaces are declared using the interface keyword, and may only contain method signature and constant declarations (variable declarations that are declared to be both static and final). An interface may never contain method definitions.
Defining an interface
Interfaces are defined with the following syntax :
[visibility] interface InterfaceName [extends other interfaces] {
        constant declarations
        abstract method declarations
}

PACKAGES IN JAVA
A Java package is a mechanism for organizing Java classes into namespaces similar to the modules of Modula. Java packages can be stored in compressed files called JAR files, allowing classes to download faster as a group rather than one at a time. Programmers also typically use packages to organize classes belonging to the same category or providing similar functionality.
A package provides a unique namespace for the types it contains.
Classes in the same package can access each other’s package-access members
Friday, May 25, 2012 0 comments

Day 12 :Date 25 May 2012



Today We were taught about the concept of the Polymorphism.Polymorphism is the ability of an object to take on many forms. The most common use of polymorphism in OOP occurs when a parent class reference is used to refer to a child class object.
Any java object that can pass more than one IS-A test is considered to be polymorphic. In Java, all java objects are polymorphic since any object will pass the IS-A test for their own type and for the class Object.
It is important to know that the only possible way to access an object is through a reference variable. A reference variable can be of only one type. Once declared the type of a reference variable cannot be changed.
The reference variable can be reassigned to other objects provided that it is not declared final. The type of the reference variable would determine the methods that it can invoke on the object.
A reference variable can refer to any object of its declared type or any subtype of its declared type. A reference variable can be declared as a class or interface type.

Types of Polymorphism in Java:-
Compile Time (Early Binding)
Run Time          (Late   Binding)

CONSTRUCTOR:-
A constructor is a special method that is used to initialize a newly created object and is  called just after the memory is allocated for the object It can be used to initialize the objects ,to required ,or default values at the time of object creationIt is not mandatory for the coder to write a constructor for the class
Thursday, May 24, 2012 0 comments

Day 11: Date 24 May 2012


Today we were taught about the concept of Inheritance in Java. Inheritance can be defined as the process where one object acquires the properties of another. With the use of inheritance the information is made manageable in a hierarchical order.
Java provides 3 types of Inheritance :-
Single Inheritance
Multilevel Inheritance
Hierarchical Inheritance
When we talk about inheritance the most commonly used keyword would be extends andimplements. These words would determine whether one object IS-A type of another. By using these keywords we can make one object acquire the properties of another object.
A program to demonstrate Inheritance.
importjava. io .*;
importjavax.swing.*;
class account{
String cust_name;
public int acc_no,cur_bal=0,acc_type,input;
public void inputfn()
{
input = Integer.parseInt(JOptionPane.showInputDialog(“Enter the amount”));
}
public void create(){
cust_name = JOptionPane.showInputDialog(“Enter the name of the customer”);
acc_no = Integer.parseInt(JOptionPane.showInputDialog(“Enter the account number”));
cur_bal = cur_bal + Integer.parseInt(JOptionPane.showInputDialog(“Enter the amount deposited”));
}
}
class current extends account
{
int input;
public void curr(){
while ((input = Integer.parseInt(JOptionPane.showInputDialog(“Press 1 to withdraw \n” +  press 2 to Deposit \n” +“press 3 to check balance \n” +“press 4 to exit”)))!=4)
{  switch(input)
{
case 1:
if (cur_bal > 5000)
{
inputfn();}
else {
System.out.print(“insufficient balance”);
}
break;
case 2:
inputfn();
cur_bal =+ input;
break;
case 3:
System.out.print(” \n Current balance is “+cur_bal);
break;
default :
System.out.print(“Wrong input”);
break;
}}} }
class saving extends account
{
int input,intrst;
public void sav()
{
while ((input = Integer.parseInt(JOptionPane.showInputDialog(“Press 1 to add interest \n” +
“press 2 to Deposit \n” +
“press 3 to check balance \n” +
“press 4 to exit”)))!=4)
{
switch (input ){
case 1:
intrst = (cur_bal * 30) /100;
cur_bal = cur_bal+ intrst;
break;
case 2:
inputfn();
cur_bal = cur_bal+ input;
break;
case 3:
System.out.print(” \n The current balance is ” +cur_bal);
break;
default:
System.out.print(“wrong input “);
break;
}}}}
public vclass bank {
/**
*
@param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int acc_type;
while ((acc_type = Integer.parseInt(JOptionPane.showInputDialog(“Press 1 for saving account \n” +
“Press 2 for current account \n Press 3 to exit”))) !=3 ){
switch (acc_type)
{
case 1:
saving a = new saving();
a.create();
a.sav();
break;
case 2:
current b =new current ();
b.create();
b.curr();
break;
default :
System.out.print(“Wrong Input”);
break;
}}}}

ABSTRACT CLASSES :- an abstract type is a type in a nominative type system which is declared by the programmer. It may or may not include abstract methods or properties that contains members which are also shared members of some declared subtype
Wednesday, May 23, 2012 0 comments

Day 10: Date 23,2012



Today we were taught about the use of Classes and Objects in JAVA.  Java follows a true Object Oriented Programming structure.
Class is a set or category of things having some property or attribute in common and differentiated from others by kind, type, or quality.
Object  is an instance of a class. The relationship is such that many objects can be created using one class. Each object has its own data but its underlying structure (i.e., the type of data it stores, its behaviors) are defined by the class.

ARRAY WITHIN A CLASS:-
We can use create array to store similar type of data items in a Class.
import javax.swing.*;
Class A
{
public void show ()
{         System.out.print(” I am in show”);       }
}
Class B
{
public static void main(string[]args)
{
A.p = new A();
p.show();
}}
NESTING MEMBER FUNCTIONS:-
Member Functions in Java Classes can be nested inside one other to form a hierarchy. One function can be called from within the other function.
import javax.swing.*;
Class AA
{
int a,b;
public void input()
{
a = JOptionPane.ShowInputDialog(“Enter the first number”);
b = JOptionPane.ShowInputDialog(“Enter the second number”);
}
private int large()
{
if (a>b)
{ return (a)}
Else {return (b)}
}
public void output()
{
System.out.print(“Large “+large());}
}
Class B
{
public static void main (String[]args)
{
a.p = new A();
p.input();
p.output();
}
}
OBJECTS AS AN ARRAY:-
Objects in java can also be stored in some array. This provides the ease of access to the programmer as the number of required variables is reduced.
Tuesday, May 22, 2012 0 comments

Day 9:Date 22 May 2012



Today we were taught about Functions in Java.Actually i should say Methods in java.A method is a set of code which is referred to by name and can be called (invoked) at any point in a program simply by utilizing the method's name.  Think of a method as a subprogram that acts on data and often returns a value. Each method has its own name.  When that name is encountered in a program, the execution of the program branches to the body of that method.  When the method is finished, execution returns to the area of the program code from which it was called, and the program continues on to the next line of code.
Basically there are two types of Methods:
Buit-in Methods
User Defined Methods
Built in methods are such Math functions,string functions etc.
whereas
User Defined Methods are defined by the User itself .User Defined Functions Can of three types:
  Without Any Arguement and Without returning a Value.
  With Arguement and Without returning a Value.
  With Arguement and With returning a Value.
Monday, May 21, 2012 0 comments

Day 8, Date 21 May 2012



Today we were taught about the concept of Nested loops in Java. The placing of one loop inside the body of another loop is called nesting.  When you "nest" two loops, the outer loop takes control of the number of complete repetitions of the inner loop and outer loops changes only when inner loop is completed.  While all types of loops may be nested, the most commonly nested loops are for loops.
We made Some patterns making programs to understand the concept of Nested loops .

Sunday, May 20, 2012 0 comments

Day 7, Date 20 May 2012


Today I just recalled everything in this week About Control statements, Loops and Array in Java.
i also tried to make some more programs using all of these .After all its a Lazy Sunday.. took some rest today...
Saturday, May 19, 2012 0 comments

Day 6: Date 19 May 2012


Today we were taught about the Arrays in Java.An array is a container object that holds a fixed number of values of a single type. The length of an array is established when the array is created. After creation, its length is fixed.Each item in an array is called an element, and each element is accessed by its numerical index
There are four types of Arrays:

1 dimensional Array
2 dimensional Array
3 dimensional Array
Jagged Array
Friday, May 18, 2012 0 comments

Day 5: Date 18 May 2012



Today We Practised Some more Programs related to the Loops.The programs are as following:


Count the Digits in a Number.
Print the Armstrong Number Series between 1 to 500
Find digit Place in a Number
Factorial of a number
Sum of Factorial Series.
Program to Count the Digits in a Number.

import javax.swing.*;
public class countdigits {

 /**
  * @param args
  */
 public static void main(String[] args) {
  // TODO Auto-generated method stub

  int num,count;
  count = 0;
  num= Integer.parseInt(JOptionPane.showInputDialog("Enter the number"));
  while (num !=0)
  {
   count ++;
   num = num /10;
  }
  System.out.print("the no. of digits is " +count);

 }
}
Program to Print the Armstrong Number Series between 1 to 500

public class armstrong
{

 /**
  * @param args
  */
 public static void main(String[] args)
  {
  // TODO Auto-generated method stub
  int a,c,d;
  int b;

  for (a=1;a<500;a++){
   b=a;
   c=b%10;
   b=b/10;
   d=b%10;
   b=b/10;
   if (a == (b*b*b)+(c*c*c)+(d*d*d))
      {
      System.out.println(a);
    }}}}
Program to Find digit Place in a Number

import javax.swing.*;
public class digitplace {

 /**
  * @param args
  */
 public static void main(String[] args) {
  // TODO Auto-generated method stub
  int num,dig,loc=0,tmp, count = 0;



  num= Integer.parseInt(JOptionPane.showInputDialog("Enter the number"));
  dig= Integer.parseInt(JOptionPane.showInputDialog("Enter the digit whose location you want to find"));
  tmp = num;
  while (num !=0)
  {
   count ++;
   num = num /10;
  }



  while (count != 0)
  {
   if (tmp % 10 == dig)
    {
     loc = count;
    }
   tmp = tmp /10;
   count --;
 
  }

  if (loc == 0)
  {System.out.println("the entered digit is not present ");}
  else{
  System.out.println("the location is "+loc);
  }
 }

}
Program to find Factorial of a Number
import javax.swing.*;
public class factorial {

 /**
  * @param args
  */
 public static void main(String[] args) {
  // TODO Auto-generated method stub
  int num,fact,c;
  fact = 1;
  num = Integer.parseInt(JOptionPane.showInputDialog("enter the number for which you want to calculate the factoral"));
  for(c=1;c<=num;c++)
  { fact = fact*c;
  }
  System.out.print("the factorial is "+fact);
    }

}


Program to Calculate Sum Of Factorial Series.
import javax.swing.JOptionPane;


public class sumoffact {

 /**
  * @param args
  */
 public static void main(String[] args) {
  // TODO Auto-generated method stub
  int num,fact,c,sum;
  fact = 1;
  sum = 0;
  num = Integer.parseInt(JOptionPane.showInputDialog("enter the number for which you want to calculate the factoral"));
  for(c=1;c<=num;c++)
  { fact = fact*c;
  sum = sum +fact;
  }
  System.out.print("the sum of factorial is "+sum);
    }

}

Thursday, May 17, 2012 0 comments

Day 4: Date:17 May 2012


Today we learnt Loops in JAVA.

There may be a sitution when we need to execute a block of code several number of times, and is often referred to as a loop. Java has very flexible three looping mechanisms. You can use one of the following three loops:
while Loop
do...while Loop
for Loop
for Each Loop
Components of a Loop
Initialization
Condition
Increment/Decrement
We made following Programs :
Reverse a number with Loop.
Calculate power of a number without Math library
Calculate Perfect Squareroot without Math library
Sum of Odd number Series
Print the Table Of any Number
Program to Reverse a number with Loop.
import javax.swing.*;
public class reversee {

 /**
  * @param args
  */
 public static void main(String[] args) {
  // TODO Auto-generated method stub

  int a,b;
  a= Integer.parseInt(JOptionPane.showInputDialog("Enter the number"));
  while (a!=0)
  {
   b=a;
   b=b%10;
   System.out.print(b);
   a=a/10;
  }


 }

}

Program to Calculate power of a number without Math library.
import javax.swing.*;
public class powercal {

 /**
  * @param args
  */
 public static void main(String[] args) {
  // TODO Auto-generated method stub
  int tmp,num,pow;
  num = Integer.parseInt(JOptionPane.showInputDialog("enter the number"));
  pow = Integer.parseInt(JOptionPane.showInputDialog("enter the power"));
  tmp = num;
  pow= pow-1;
  while (pow!= 0)
  {
   pow = pow-1;
   tmp = tmp * num;
  }
  System.out.print("the answer is "+tmp);
  }
}
Program to Calculate Perfect Squareroot without Math library.
import javax.swing.JOptionPane;
class sqrot {

public void abc (){
// TODO Auto-generated method stub
int num,a,b,c,flag;
flag=0;
num= Integer.parseInt(JOptionPane.showInputDialog("Enter the number"));
b= num/2;
for (a=1;a
{
c = a*a;
if (num == c){
flag = 1;
System.out.print("the perfect square root of "+num +" is "+a);

}

}

if (flag == 0)
{
System.out.print("the entered no "+num +" is not a perfect square");
}

}

}

public class sqroot_class {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
sqrot s = new sqrot();
s.abc();

}
}

Program to Calculate Sum of Odd number Series
import javax.swing.*;
public class sumofodd {

 /**
  * @param args
  */
 public static void main(String[] args) {
  // TODO Auto-generated method stub
  int limit,a,sum;
  sum= 0;
  limit = Integer.parseInt(JOptionPane.showInputDialog("enter the no. upto which you want to fint the sum"));
  a=1;
  while (a<=limit)
  {
   sum = sum + a;
   a= a+2;
 
  }

  System.out.print("the sum is "+sum);


 }

}
Program To Print The Table Of Any Number.
import javax.swing.*;
public class table {

 /**
  * @param args
  */
 public static void main(String[] args) {
  // TODO Auto-generated method stub
  int num,a,ans;
  num = Integer.parseInt(JOptionPane.showInputDialog("Enter the number"));
  for (a=1;a<=10;a++)
  {
   ans = num * a;
   System.out.println(num +" x "+a +" = "+ans);
  }
  }
                 }
Wednesday, May 16, 2012 0 comments

Day 3: Date 16 May 2012


Today we were taught About Switch Case in JAVA.Unlike if-then and if-then-else statements, the switch statement can have a number of possible execution paths. A switch works with the byte, short, char, and int primitive data types. It also works with enumerated types (discussed in Enum Types), the String class, and a few special classes that wrap certain primitive types: Character, Byte, Short, and Integer (discussed in Numbers and Strings).


We made following program to understand the use of it :
Program to Convert binary to decimal, decimal to binary , octal to decimal,decimal to octal.
import javax.swing.*;
public class switchcase {


/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int r,b,a,count,ans,an,input,d,rep=0;
while (rep != 1){
input = Integer.parseInt(JOptionPane.showInputDialog("Press 1 for binary to decimal conversion \n " +
  "Press 2 for decimal to binary conversion\n" +
  "Press 3 for decimal to octal conversion\n" +
  "Press 4 for octal to decimal conversion\n"));


switch (input)
{
case 1:
//binary to decimal
b=1;ans=0;
a = Integer.parseInt(JOptionPane.showInputDialog("Enter a binary no."));
if (a == 0)
{System.out.print("0");}
else {
while(a !=0)
{ 
r = a % 10;
a = a/10;
an = r * b;
ans= ans+an;
b = 2*b;


}
System.out.println(ans);
} rep = Integer.parseInt(JOptionPane.showInputDialog("press 1 to quit the program or \n press 0 to restart the program"));
break;


// decimal to binary 
case 2:


b= 2;
an = Integer.parseInt(JOptionPane.showInputDialog("Enter a decimal no."));
if (an == 0)
{System.out.print("0");}
else {
while (an !=0){
r = an % 2;
an = an /2;




b = (b*10) + r;
} 
System.out.println("entered no. in binary equals ");


while (b!=2)
{
a=b;
a=a%10;
System.out.print(a);
b=b/10;
}




}rep = Integer.parseInt(JOptionPane.showInputDialog("press 1 to quit the program or \n press 0 to restart the program"));
break;
//decimal to octal
case 3:
b= 9;
an = Integer.parseInt(JOptionPane.showInputDialog("Enter the number"));
if (an == 0)
{ 
System.out.print("0");
}
else {
while (an !=0){
r = an % 8;
an = an /8;




b = (b*10) + r;
} 
System.out.println("entered no. in binary equals ");


while (b!=9)
{
a=b;
a=a%10;
System.out.print(a);
b=b/10;
}
}rep = Integer.parseInt(JOptionPane.showInputDialog("press 1 to quit the program or \n press 0 to restart the program"));
break;




// octal to decimal


case 4:


int flag = 0;
b=1;ans=0;
a = Integer.parseInt(JOptionPane.showInputDialog("Enter an octal no."));
if (a == 0)
{System.out.print("0");}
else {
while(a !=0 && flag ==0)
{ 
r = a % 10;
if (r > 8)
//System.out.print("the value of r is "+r +"\n");
{ flag = 1;


}
a = a/10;
an = r * b;
ans= ans+an;
b = 8*b;


}
if (flag == 1)
{System.out.println("Invalid input");
}
else{
System.out.println(ans);}
} rep = Integer.parseInt(JOptionPane.showInputDialog("press 1 to quit the program or \n press 0 to restart the program"));
break;
default:
System.out.println("invalid input");
rep = Integer.parseInt(JOptionPane.showInputDialog("press 1 to quit the program or \n press 0 to restart the program"));
break;


//switch ends here
}


// while ends here(repeat)
}








}


} 

Tuesday, May 15, 2012 0 comments

Day 2 :Date15 May 2012


Today firstly Teacher Discussed the programs that was given yesterday.Then after  disscusion we were taught about the Control Statements in java such as if else, ladder if else, nested if else statements.A program consists of a number of statements which are usually executed in sequence. Programs can be much more powerful if we can control the order in which statements are run.We use Control statements to Do So.


we were given following programs to make ourselves:
Check Given number is postive or negative.
Check Given number is even or Odd.
Check Given number's reverse is Equal to Original Or Not.
Check Given number is Armstrong or not.
Check Profit or loss by input of Cost price and Sale price from User.
Check Date is Valid or Invalid.
Program to Check Given number is postive or negative.
import javax.swing.*;
public class positiveornot {

 /**
  * @param args
  */
 public static void main(String[] args) {
  // TODO Auto-generated method stub
 int a;
 a = Integer.parseInt(JOptionPane.showInputDialog("enter the no."));
 if (a>=0)
 { System.out.print("the no is positive");
 }
 else
 { System.out.print("the no is negative");
 }

}}

Program to Check Given number is Even or Odd.
import javax.swing.*;
public class even {

 /**
  * @param args
  */
 public static void main(String[] args) {
  // TODO Auto-generated method stub
  int a;
  a = Integer.parseInt(JOptionPane.showInputDialog("enter the no."));
  if (a%2 ==0)
  { System.out.print("the no. is even");
 
  }
  else {System.out.print("the no. is odd");}
 }

 }

Program to Check reverse of number is equal to original or not.
import javax.swing.*;
public class samerev {

 /**
  * @param args
  */
 public static void main(String[] args) {
  // TODO Auto-generated method stub
  int a,b,c,d;
  a = Integer.parseInt(JOptionPane.showInputDialog("enter the no."));
  c=a%10;
  a=a/10;
  b=a%10;
  a=a/10;
  d= (c*100)+(b*10)+(a);
  if(a == d)
  {
   System.out.print("the reverse of the no. is same " );
  }
  else { System.out.print("the reverse is not same ");}
 }

}
Program to Check Given Number is Armstrong Or Not.
import javax.swing.*;
public class amstrong {


 public static void main(String[] args) {



  int a,b,c,d,temp;
  a = Integer.parseInt(JOptionPane.showInputDialog("enter the no."));
  temp =a;
  c=a%10;
  a=a/10;
  b=a%10;
  a=a/10;
  d = (a*a*a)+(b*b*b)+(c*c*c);
  if(temp == d )
  {
   System.out.print("it is a armstrong");
  }
  else
  {
   System.out.print("it is not armstrong ");
  }
 }

}

Program to Check Profit or loss by input of Cost price and Sale price from User.
import javax.swing.*;
public class costprice {

 /**
  * @param args
  */
 public static void main(String[] args) {
  // TODO Auto-generated method stub
  int cp,sp,p;
  cp = Integer.parseInt(JOptionPane.showInputDialog("enter the costprice"));
  sp = Integer.parseInt(JOptionPane.showInputDialog("enter the selling price"));
  if (cp < sp)
  {
   p = sp - cp;
   System.out.print("the profit is "+p);
  }
  else if (cp > sp)
  {
   p = cp-sp;
   System.out.print("the loss is "+p);
  }
  else
  {
   System.out.print("there is neither any profit nor loss");
  }

 }

}

Program to Check Date is VAlid Or Not.
import javax.swing.*;
public class validdate {

 /**
  * @param args
  */
 public static void main(String[] args) {
  // TODO Auto-generated method stub
 int date,month;
 month = Integer.parseInt(JOptionPane.showInputDialog("enter the month"));
 date = Integer.parseInt(JOptionPane.showInputDialog("enter the month"));
 if (month==1  || month == 3 || month== 5 ||month==7 ||month==8|| month==10 ||month==12)
 {

  if( date>0 && date<32)
  {
   System.out.print("It is a valid date");
  }
  else
  {System.out.print("it is invalid date");
  }
 }




 /** 30 days **/



 else if (month==4  || month == 6 || month== 9 ||month==11)
 {

  if( date>0 && date <31)
  {
   System.out.print("It is a valid date");
  }
  else
  {System.out.print("it is invalid date");
  }
 }


 /** 28 days**/

 else if (month==2 )
 {

  if( date>0 && date <29)
  {
   System.out.print("It is a valid date");
  }
  else
  {System.out.print("it is invalid date");
  }
 }


 else
 {
  System.out.print("invalid date");

 }


 }

}

Monday, May 14, 2012 0 comments

Day 1 Date :14 May 2012

Day 1 Date :14 May 2012

Today was the first day of my training in core java at RICCS Education Institute, Ludhiana.In the first class we were told about the history and evolution of Java,its basic features.Java was originally called OAK, and was designed for handheld devices and set-top boxes. Java is the programming language which was developed at Sun Microsystems(now Oracle) by a team led by James Gosling. It combines the best features of C and C++ Language. It is also called as truely OOPS language because you must have to create a Class for every program.We were also given the introduction to the Syntax Of Java and We also made the ubiquitious  "Hello world" Program . We also learned about Static And Non Static function.


Then we also made following programs:




Swap two numbers with the help of third variable.
Swap two numbers without the help of third variable.
Reverse a no. with 3 digits.



Program to Swap two Numbers with the help of Third Variable.


Class Swap
{
public static void main(String[] args)
 {
int a,b,c;
a=10;
b=20;
System.out.print("Values Before Swapping A="+a "B=" +b);
c=a; 
a=b;
b=c;
System.out.print("Values After Swapping A="+a "B=" +b);
}
}


Program to Swap two Numbers without the help of Third Variable.


Class Swap2
{
public static void main(String[] args)
 {
int a,b;
a=10;
b=20;
System.out.print("Values Before Swapping A="+a "B=" +b);
a=a+b; 
b=a-b;
a=a-b;
System.out.print("Values After Swapping A="+a "B=" +b);
}
}
Program to reverse a number


Class Rev
{
public static void main(String[] args)
 {
int a,b,no;
no=123;
a=no%10;
no=no%10;
b=no%10;
no=no%10;
no=a*100+b*10+no;
System.out.print("Reverse number is:" +no) ;
}
 
;