title: Creating a Calendar in Java (Netbeans)
body: <p>I'm writing my program for a calendar, however, I have the format for my calendar, but I don't know how to get the days to go on top of the numbers. I'm trying to get (Sun, Mon, Tue, Wed, Thu, Fri, Sat) on top of the respective date. Also, my code keeps printing out the first day of every month and I don't want that, I want it to print the month and the year at the top, yet I'm not sure what I'm doing wrong.</p>
  
  <pre><code>package prog3;
  
  import java.util.Scanner;
  
  public class Prog3 {
  
      public static void main(String[] args) {
          Scanner scan = new Scanner(System.in);
          int month = 0;
          int year = 0;
          do {
              System.out.print("Please enter a month (1-12): ");
              while (!scan.hasNextInt()) {
                  System.out.print("The month must be an integer: ");
                  scan.next();
              }
              month = scan.nextInt();
              if (month &lt; 1 || month &gt; 12) {
                  System.out.println("Value is not in range");
              }
          } while (month &lt; 1 || month &gt; 12);
  
          do {
              System.out.print("Please enter a year (2000-2100): ");
              while (!scan.hasNextInt()) {
                  System.out.print("The year must be an integer: ");
                  scan.next();
              }
              year = scan.nextInt();
              if (year &lt; 2000 || year &gt; 2100) {
                  System.out.println("Value is not in range");
              }
          } while (year &lt; 2000 || year &gt; 2100);
  
          String monthName = "unknown";
          int lastDayOfMonth = 0;
          int firstDayOfMonthDayOfWeek = 0;
          switch (month) {
              case 1:
                  monthName = "January";
                  lastDayOfMonth = 31;
                  break;
              case 2:
                  monthName = "February";
                  if (year / 4 == 0 &amp;&amp; (year / 100 != 0 || year / 400 == 0)) {
                  lastDayOfMonth = 29;
                  } else {
                      lastDayOfMonth = 28;
                  }
                  break;
              case 3:
                  monthName = "March";
                  lastDayOfMonth = 31;
                  break;
              case 4:
                  monthName = "April";
                  lastDayOfMonth = 30;
                  break;
              case 5:
                  monthName = "May";
                  lastDayOfMonth = 31;
                  break;
              case 6:
                  monthName = "June";
                  lastDayOfMonth = 30;
                  break;
              case 7:
                  monthName = "July";
                  lastDayOfMonth = 31;
                  break;
              case 8:
                  monthName = "August";
                  lastDayOfMonth = 31;
                  break;
              case 9:
                  monthName = "September";
                  lastDayOfMonth = 30;
                  break;
              case 10:
                  monthName = "October";
                  lastDayOfMonth = 31;
                  break;
              case 11:
                  monthName = "November";
                  lastDayOfMonth = 30;
                  break;
              case 12:
                  monthName = "December";
                  lastDayOfMonth = 31;
                  break;
          }
  
          int day = 1;
          int y = year;
          int m = month;
          int q = day;
  
          if (month == 1 || month == 2) {
              m = month + 12;
              y = year - 1;
          }
          int h = (q + (int) ((26 * (m + 1)) / 10) + y + (int) (y / 4)
              + 6 * (int) (y / 100) + (int) (y / 400)) % 7;
          switch (h) {
              case 0:
                  h+=7;
                  System.out.println("Saturday.");
                  break;
              case 1:
                  System.out.println("Sunday.");
                  break;
              case 2:
                  System.out.println("Monday.");
                  break;
              case 3:
                  System.out.println("Tuesday.");
                  break;
              case 4:
                  System.out.println("Wednesday.");
                  break;
              case 5:
                  System.out.println("Thursday.");
                  break;
              case 6:
                  System.out.println("Friday.");
                  break;
          }
          int currentDay = 2 - h;
          boolean done = false;
          while (!done) {
              for (int col = 1; col &lt;= 7 &amp;&amp; !done; ++col) {
                  if (currentDay &gt; 0) {
                      System.out.printf("%2d ", currentDay);
                      System.out.printf("   ");
                  }
                  else {
                      System.out.printf("      ");
                  }
                  if (currentDay &gt;= lastDayOfMonth) {
                      done = true;
                  }
                  ++currentDay;
              }
              System.out.println();
          }
      }
  
  }
  </code></pre>