Showing posts with label Month Calendar Generator in Java. Show all posts
Showing posts with label Month Calendar Generator in Java. Show all posts

Sunday, December 15, 2019

Month Calendar Generator in Java

I wrote this program to generate month calendar using Java programming ten years ago while learning how to program in Java.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod City, Negros Occidental I also accepting computer repair, networking and Arduino Project development at a very affordable price.

My personal website is http://www.jakerpomperada.com

My programming website is http://www.jakerpomperada.blogspot.com

I am also a book author you can purchase my books on computer programming and information technology in the following links below.

https://www.mindshaperspublishing.com/
https://www.unlimitedbooksph.com/

If you like my video tutorials kindly click the like button and subscribe for more video tutorials on my channel.

Thank you very much for your help and support.
 
 
 
 
 
Program Listing
 
calendar.java
 

// calendar.java
// author  : Mr. Jake Rodriguez Pomperada, MAED - Instructional Technology
// date    : March 18, 2009 Tuesday 2:05 PM
// tool    : Java
// email   : jakerpomperada@yahoo.com
// tel. no.: +63 034 4335081
//
// program description:
//
// Argument Month and Day Calendar in Java implementation




import java.util.*;

class calendar
{
        public static void main(String arg[])
        {
              GregorianCalendar c1 = new GregorianCalendar();
              int month  = Integer.parseInt(arg[0]);
              int year = Integer.parseInt(arg[1]);
              month = month-1;
              c1.set(year,month,1);
              int day = c1.get(Calendar.DAY_OF_WEEK);
              System.out.println(day);
              int numdays = 0;

        switch(c1.get(Calendar.MONTH))
        {
           case 0:
           case 2:
           case 4:
           case 6:
           case 7:
           case 9:
           case 11:
                numdays = 31;

                break;
           case 1:
                if(c1.isLeapYear(c1.get(Calendar.YEAR)))
                   numdays = 29;
                else
                   numdays = 28;
                   break;
           case 3:
           case 5:
           case 8:
           case 10:
                 numdays = 30;
                 break;
        default:
                System.out.println("ERROR IN MONTH SPECIFICATION");
                break;
       }
       display(day,numdays);

       }
       static void display(int sday , int tday)
         {
              int k = 0;

              System.out.print("\n\n");
              System.out.print("\n=========================================");
               System.out.print("\n    MONTH AND YEAR CALENDAR VERSION 1.0");
              System.out.print("\n=========================================");

              System.out.print("\n\n");
              System.out.println(" SUN  MON  TUE  WED  THU  FRI  SAT ");
              for(int j = 1;j <= sday-1; j++)
              {
               System.out.print("     ");
               k++;
              }
             for(int i = 1;i <= tday;i++)
             {
               if(i < 10)
                System.out.print("  "+"0"+i+" ");
               else
                System.out.print("  "+i+" ");
               k++;
               if ( k == 7)
               {
                System.out.println();
                k = 0;
               }
             }
             System.out.print("\n\n");
              System.out.print("\n==================================================");
                 System.out.print("\n   Created By: Mr. Jake R. Pomperada, MAED-IT    ");
              System.out.print("\n==================================================");

           System.out.print("\n\n");

          System.exit(1);

      }
 }  // End of Code