Monday, October 18, 2010

Fun with Java-Part 1 (Calendar) Contd..



This is the main logic class.
It does not contain a main method.
Create a folder named calendarlogic and paste the class in that folder.


Download this Code click
__________________________________________________________________________________
//---------------------------------------CODE SNIPPET---------------------------------------------------

package calendarlogic;

/**
 *
 * @author Nayak
 */
public class Calendarlogic {

/*----------------------Author Arani Nayak----------------------------*/
/*---------------------Calender (Version3.1)--------------------------*/




 int a,year,diff,d,i=1,j,k,dm,l;
 long days;
 int st=1900,ch;
 int month;


        /// Creating a constructor named Calendarlogic, with intake parameters y, and m
        /// y will intake year as input and m the month to be displayed.. Both the value will
        /// be in integers...


        public Calendarlogic(int y, int m) {    
          
        this.year = y;
        this.month = m;

     if(year<1900 || year>5000)
     {

         System.out.println("Enter an year within 1900-5000 A.D.");

     }

     else{

          if(month>=1 && month <=12)
          {

        a=0;
                for(i=st;i
                  {
                   if((i%400==0) || (i%4==0 && i%100!=0))
                   a++;
                   }

   if(month==1 || month==3 ||month==5 || month==7 || month==8 || month==10 ||month==12)
   dm=31;
   else if(month==2)
   dm=28;
   else dm=30;
   if((month==2) && ((year%400==0) || (year%4==0 && year%100!=0)))
   dm=29;

  System.out.format("%20d",year);
  System.out.print(" ");
  if(month==1){System.out.print("Jan");  l=0;}
  if(month==2){System.out.print("Feb");  l=31;}
  if(month==3){System.out.print("Mar");  l=59;}
  if(month==4){System.out.print("Apr");  l=90;}
  if(month==5){System.out.print("May");  l=120;}
  if(month==6){System.out.print("Jun");  l=151;}
  if(month==7){System.out.print("Jul");  l=181;}
  if(month==8){System.out.print("Aug");  l=212;}
  if(month==9){System.out.print("Sep");  l=243;}
  if(month==10){System.out.print("Oct"); l=273;}
  if(month==11){System.out.print("Nov"); l=304;}
  if(month==12){System.out.print("Dec"); l=334;}

                System.out.println("");

 if((month>2) && ((year%400==0) || (year%4==0 && year%100!=0)))
   l++;

  diff = year-st;
  days = diff*365+a+l;


  if(days%7==0)
   d=0;
  else if(days%7==1)
   d=1;
  else if(days%7==2)
   d=2;
  else if(days%7==3)
   d=3;
  else if(days%7==4)
   d=4;
  else if(days%7==5)
   d=5;
  else
   d=6;

  System.out.println("  Mon  Tue  Wed  Thu  Fri  Sat  Sun");
        for(j=0;j<5*d;j++)
            System.out.print(" ");
   i=1;

  for(j=0;j<6;j++){
        for(k=d;k<7&&i<=dm;k++){
            System.out.format("%5d",i);
            i++; }
   d=0;
  System.out.println("");
    }
              
                    } //end of if(month checking)

          else{
                System.out.println("Value of month Entered should be within 1-12");
          }

                }// end of else


            } // end of constructor

}// end of class

_________________________________________________________________________________


Driver class to use the above Java class :
Download this Code click
__________________________________________________________________________________




import calendarlogic.Calendarlogic;
/**
 *
 * @author Nayak
 */
public class Main {


    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
       
        Calendarlogic cl = new Calendarlogic(2010,10);
    }


}


__________________________________________________________________________________


N.B: Feel free to copy the code.

Thursday, October 7, 2010

Just a Click and Keep Earning!!

Getting bored of doing nothing???
or want some pocket money??
Here what u can do.
Start Earning by just reading SMS......


Sounds unbelievable...it's true.....
There are two requisites that you need. First, you should have a mobile phone. Second, your phone should be able to receive messages. That’s all :) Another thing, you might or might not need this, referring your friends who are also interested in this same thing.


What's Best about this opportunity??


It Costs Nothing To You....So Why Not Give it A Try??


Click here or the banner below :



 

Wednesday, October 6, 2010

Fun with Java-Part 1

Let's have some fun using Java

Let's build a calendar using Java
The logic behind developing a calendar is very simple. You just have to know a particular date and which date it was, and on this basis you can calculate any date.
For example 1st January 1900 was a Monday, knowing this you can calculate any day.
How???
First of all you have to calculate the no. of days in between your desired date and 1st january 1900. Then divide the no. of days by 7.
If the remainder is 0 (zero) that day is also a Monday, if the diff. is 1 the day is Tuesday and so on.
If(No. of Days) % 7 == 0 (Then Monday)
If(No. of Days) % 7 == 1 (Then Tuesday )
…………………………….
If(No. of Days) % 7 == 6 (Then Sunday )
How to find out the no. of days ???
Very simple!! First find out the no. of years,then the no. of leap years in between your req. yr. and 1900.
Total No. of Days = (No. of yrs. * 365)+(No. of leap years)+(No. of days in the given yr. before the req. date)
For example, let us consider that you want to find out which day will be 1st Nov. 2008.
No. of yrs. Between 1900 & 2008 = 108
No. of leap yrs.= 26
No. of days in the yr. 2008 before 1st nov. = 304
So Total No. of Days= (108*365) + 26 + 304= 39750
But do not forget that the yr. 2008 is itself a leap yr. so add another day to the total count (+1) = 39751

39751 % 7 = 5 (i.e. Saturday)  

Now, try to implement this in code. You will get the source code in
the next week.
Some Hints:
(i) How to find whether a year is a leap yr. or not??
 (If the yr. is divisible by 400, it is undoubtedly a leap yr. ex. 2000,1600, etc. If the yr. is divisible by 4 but not divisible by 100 it is a leap yr. ex. 1900 is divisible by 4 but since it is also divisible by 100 it is not a leap yr. whereas 2008 is divisible by 4 & not divisible by100 so it is a leap yr.
(ii) Use  long as the data type to store the no. of days as the number may be huge.
(iii) Follow OOP concept. Like keep the main calendar logic in a separate Java class, and create a driver class(main class) to feed year and month to the Calendar class.

N.B: I will be posting the code in the following week, try to solve it in the meanwhile, post it if you succeed.

Output Should be as following



Tuesday, October 5, 2010

Harry Potter Final Chapter-Part 1


Releasing on 19th November 2010, is the first part of the final novel "Harry Potter & the Deathly Hallows", one of the most read series of recent times, penned by J.K.Rowling who's fame from anonymity is almost like a fairy tale.

Warner's Brothers decided to split the final book into two parts, the first part is releasing this year.
A clever marketing strategy or a decision to make justice to the phenomenal series?
Let's wait  till 19th Nov. to find out and let's hope this part does justice to the story unlike the previous ones.

Monday, October 4, 2010

Window Phone 7 to bury iPhones, Androids? - Business news


http://www.siliconindia.com/shownews/iPhone_Android_soon_to_be_buried_by_Microsoft-nid-72230.html?utm_campaign=Newsletter&utm_medium=Email&utm_source=Subscriber

Window Phone 7  to bury iPhones, Androids?-Business news- Seattle:About hundred Microsoft employees acted their fantasy with a mock funeral of Apple iPhones and, marked the completion of its Window Phone 7

--
Sent via http://www.addtoany.com



--

Scientific Calculator

Book mark this page:
may come handy if u need a calculator. no need to search for one while u r online..




Web 2.0 scientific calculator

Friday, October 1, 2010

Wipro Technologies

Wipro technologies..
Minimum criteria for 10h and 12, 50%...
Last date 4th October