How to display calendar

So I've been working on this problem but i am stuck in the formating of the days integers for each calendar month
here is the problem
Displaying calendars (filename: DisplayCalendars.java)
Design an algorithm and then write a Java program that prompts the user to enter the year and first day of the year, and displays the calendar table for the year on the console. For example, if the user entered the year 2005, and 6 for Saturday, January 1, 2005, your program should display the calendar for the 12 months in the year, as follows:
January  2005
Sun     Mon     Tue     Wed     Thu     Fri     Sat
1     
2      3      4      5      6      7      8     
9      10     11     12     13     14     15     
16     17     18     19     20     21     22     
23     24     25     26     27     28     29     
30     31     
February  2005
Sun     Mon     Tue     Wed     Thu     Fri     Sat
1      2      3      4      5     
6      7      8      9      10     11     12     
13     14     15     16     17     18     19     
20     21     22     23     24     25     26     
27     28     Can anyone please help me
I need to display this on the console (ie.system.out.print...)

ok
here is my code:
*This program determines the number of days in any month for any year (including leap years) and displays the
*result in a dialog box.
import java.util.Scanner;
public class DisplayCalendars
     //main method:
     public static void main(String[] args)
          //Create a new scanner to get the numbers
        Scanner scanner = new Scanner(System.in);
        //Enter an integer representing the first day of year
          System.out.print("Enter an integer 0-6, for the first day of the year: ");
          int day = scanner.nextInt();
          //Enter an integer representing the year
          System.out.print("Enter an integer representing the year: ");
          int year = scanner.nextInt();
        String sString = " ";
        int Days = 0;
             //Initialize the S string for naming months of the year
               String dString = " ";
            String mString = " ";
    switch (day)
               case 0:  dString = "Sunday"; mString = "January";
                    break;
               case 1: dString = "Monday"; mString = "January";
                    break;
               case 2: dString = "Tuesday"; mString = "January";
                    break;
               case 3: dString = "Wednsday"; mString = "January";
                    break;
               case 4: dString = "Thursday"; mString = "January";
                    break;
               case 5: dString = "Friday"; mString = "January";
                    break;
               case 6: dString = "Saturday"; mString = "January";
                    break;
               default: System.out.println("Errors: invalid number");
                    System.exit(0);
          //for each of the 12 months
        int month;
        for(month = 1 ; month <= 12 ; month++)
            switch (month)
               case 3: Days = 31; sString = "March";
                    break;
               case 4: Days = 30;  sString = "April";
                    break;
               case 5: Days = 31;  sString = "May";
                    break;
               case 6: Days = 30;  sString = "June";
                    break;
               case 7: Days = 31; sString = "July";
                    break;
               case 8: Days = 31; sString  = "August";
                    break;
               case 9: Days = 30; sString = "April";
                    break;
               case 10: Days = 31; sString = "September";
                    break;
               case 11: Days = 30;  sString = "October";
                    break;
               case 12: Days = 31;  sString = "November";
                    break;
               case 1: Days = 31;  sString = "January";
                    break;
               case 2: if (((year % 4 == 0) && (year % 100 != 0))
                    || (year % 400 == 0))
                    Days = 29;  sString = "February";
               else {
                    Days = 28;  sString = "February";
                    break;
               default: System.out.println("Errors: invalid number");
                    System.exit(0);
           System.out.println("\n\n\t\t\t\t\t\t" + sString + "\t" + year);
            System.out.println("_________________________________________________________________\n");
            System.out.printf("%10s%10s%10s%14s%12s%10s%13s\n", "Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday\n");
     for (int i=1; i<=day; i++) {
          System.out.print("");
          if (month<=12)
          for (int B=1; B<=Days; B++)
          System.out.print(B);
}The formatting issue that I have is it has to do with lining up the numbers to the days.

Similar Messages

  • How to display calendar in web part with selected month(jan,feb,march) in sharepoint 2013

    Hi All,
    How to display selected Month like jan,feb,march in single page with different webparts.
    I created 3 webparts and selected(jan,feb,march) but when page refreshes all webparts are displaying current month(December).
    Here i attached the screen shot, where December should be shown as (January and February)
    Kindly check and guide me in right track.
    Thanks
    Prabhat.
    Madhu Prabhat

    Hi,                                                             
    To develop a custom web part, you can take a look at the links below with steps in detail for a start:
    Creating Web Parts for SharePoint
    http://msdn.microsoft.com/en-us/library/ee231579.aspx
    Sharepoint 2013 Create a Visual Web Part
    http://raquelalineblog.wordpress.com/2013/04/25/sharepoint-2013-create-a-visual-web-part/
    Another three links for your reference:
    http://www.learningsharepoint.com/2012/12/24/how-to-create-a-custom-webpart-in-sharepoint-2013/?goback=%2Egde_3911588_member_198759022#%21
    http://www.youtube.com/watch?v=9iK8IPUB87w
    http://sptechbytes.blogspot.com/2013/10/sharepoint-2013-creating-visual-webpart_26.html
    Here are some samples of custom calendar web part for your reference:
    http://www.codeproject.com/Articles/108676/SharePoint-Custom-Calendar
    http://gunnarpeipman.com/2009/01/creating-sharepoint-global-calendar/
    https://blog.metrostarsystems.com/2013/10/21/creating-a-custom-sharepoint-calendar-rollup/
    You can also do more customization by adding your own logic in it.
    Best regards
    Patrick Liang
    TechNet Community Support

  • How to display Calendar view without having to select date

    Hi there,
    I would like to know can I display Calendar view without having user to select date first.
    And also, how do I highlight the date in calendar view for example, to show that i have set a reminder on that date?
    I have searched many threads before, but I could not get the final answer.

    Hi,
    Is there a way to display a full calendar popup with time stamp so the users can pick the timestamp from the popup?Date Picker doesn't have this feature. You can use Javascript to achieve the same. But at same time it's highly unrecommended to use javascript with OAF pages.
    Regards,
    Gyan

  • How to display calendar in prompts

    Is there any way we can show calendar in date prompt? So that user can select any date from calendar.

    Thanks. I saw in Dashboard prompt.
    But I could not understand datetime/date in rpd. Could you please explain more in detail if you do not mind?
    By the way how to use dashboard prompt in answer?
    I follow below step:
    - Create Dashboard prompt
    - Select Calendar from Control Option
    - Set variable to Presentation variable and name it 'date_prompt'
    - Save it.
    Then I create a report. I click filter icon then Add=> Variable=> Presentation. I had wrote 'date_prompt' on Variable Expr. But it is not prompting any thing....

  • How to display two calendars in a page

    Hi,
    I use Calendar wizard to display calendar in HTML DB. I am not able to display more than one calendar. Any help is highly appreciated.
    Thanks,
    Sathya.

    i) goto WIZARD tab after choosing your application.
    ii) In the WIZARD tab, click on calendar and give the inputs required. Try to create one more calendar on the same page once you have created your first one.
    iii) My HTML DB version is 1.5
    In addition, It would be great if you can tell me how to fill up colors in the cells, once you are able to create the calendar.
    Thanks.

  • How to display Date Calendar in Oracle BI Answers Prompts (parameter)

    I'm still new to OBIEE.
    How to display Date Calendar in Oracle BI Answers Prompts (parameter)?
    Thanks.

    Hi,
    While creating Dash Board prompt choose the control to 'Calendar'.
    I think it is not possible to provide 'Calendar' control using Prompts tab while creating request.
    It is possible to write Java Script for a Column of data type 'char'. So, cast the date data type to char.
    Go to: Column Properties --> Data Format
    Choose override default data format to view the available options in the drop down list.
    I would be very happy if anybody acknowledge me that I am wrong.
    -Vency

  • How to Display Two Months in Sharepoint Calendar

     
    1. I have SharePoint Server. Do I need other software to the make the following change in Calendar?
    2. How to hide Saturday and Sunday or move Sunday to the first day. (Sunday is the last day in my current calendar. )
    3. How to display two months on one page?
    Thanks.

    Hello,
    For those still looking, you should ask on the
    SharePoint forums.
    Karl
    When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer.
    My Blog: Unlock PowerShell
    My Book: Windows PowerShell 2.0 Bible
    My E-mail: -join ('6F6C646B61726C40686F746D61696C2E636F6D'-split'(?&lt;=\G.{2})'|%{if($_){[char][int]&quot;0x$_&quot;}})

  • How to make calendar automatically display special events

    hi, i wanted to make my calendar automatic display the events in a specific month. should i use ifelse statement or switch case statement? my web site have display calendar for the current month. it aotumatically update. now i wanted to highlight the special event on that month like New Year, Christmas etc. it automatically change the event according to the month. when it comes to May, it won't display April event but May event such as Labour Day. this is the example, what i wanted it to be is the event date changes according to the month.
    <html>
    <head>
    <title>Brunsfield e-Homes</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <link rel="stylesheet" href="home.css">
    <style type="text/css">
    .main {
    width:130px;
    border:0px solid #8D549B;
    border-collapse:collapse;
    .month {
    background-color:#8D549B;
    font:bold 11px arial;
    color:white;
    border-collapse:collapse;
    border:0px solid #8D549B;
    .daysofweek {
    background-color:#C78FB9;
    font:bold 9px arial;
    color:#000000;
    border-collapse:collapse;
    border:0px solid #8D549B;
    .days {
    font-size: 9px;
    font-family:arial;
    color:black;
    background-color: #FADBF2;
    padding: 1px;
    border-collapse:collapse;
    border:0px solid #8D549B;
    .days #today{
    font-weight: bold;
    color: #cc0000;
    border-collapse:collapse;
    border:0px solid #8D549B;
    </style>
    <script type="text/javascript" src="basiccalendar.js">
    * Basic Calendar-By Brian Gosselin at http://scriptasylum.com/bgaudiodr/
    * Script featured on Dynamic Drive (http://www.dynamicdrive.com)
    * This notice must stay intact for use
    * Visit http://www.dynamicdrive.com/ for full source code
    </script>
    </head>
    <body bgcolor="#FFFFFF" leftmargin="5" topmargin="0" marginwidth="0" marginheight="0" oncontextmenu="return false">
    <!-- ImageReady Slices (home.psd) -->
    <div style="position:absolute; left:0; top:64">
    <table>
    <td width="140" align="center" valign="top">
         <font size="1">eCalender</font>     
         <script type="text/javascript">
         var todaydate=new Date()
         var curmonth=todaydate.getMonth()+1 //get current month (1-12)
         var curyear=todaydate.getFullYear() //get current year                         
         document.write(buildCal(curmonth ,curyear, "main", "month", "daysofweek", "days", 1));
    </script>
    </td>
    </table>
    <table width="130" align="center" border="0" bgcolor="#FDC2D6">
    <tr>
         <td class="events" width="20" align="center">1</td>
         <td class="events" align="left">April Fools Day</td>
         </tr>
         <tr>
         <td class="events" width="20" align="center">4</td>
         <td class="events" align="left">Ching Ming Festival</td>
         </tr>
         <tr>
         <td class="events" width="20" align="center" valign="top">8</td>
         <td class="events" align="left">Birthday of Sultan Johor</td>
         </tr>
         <tr>
         <td class="events" width="20" align="center">9</td>
         <td class="events" align="left">Good Friday</td>
         </tr>
         <tr>
         <td class="events" width="20" align="center">11</td>
         <td class="events" align="left">Easter Sunday</td>
         </tr>
         <tr>
         <td class="events" width="20" align="center" valign="top">19</td>
         <td class="events" align="left">Birthday of Sultan Perak</td>
         </tr>
         <tr>
         <td class="events" width="20" align="center">22</td>
         <td class="events" align="left">Earth Day</td>
         </tr>
         <tr>
         <td class="events" width="20" align="center">25</td>
         <td class="events" align="left">Secretary Day</td>
         </tr>
    </table>     
    </body>
    </html>

    http://www.dotjonline.com/main/index.jsp?url=/taglib/calendar/calendarFixed.jsp

  • How to display Current Year and Month in Drop Down list

    Hi Dear friends,
    I am devloping a report. It has got 2 pages--input and output(Report) page.
    IN input page, user will select Month and Year from drop down list as one of the input parameters. (seperate drop down list 4 month and year)
    Now, my problem is:
    HOw to display current month and year by default in the dropdown list...........
    I hope my question is clear.
    Please help.
    Regards,
    ASh

    NO da,
    it is not working.
    First i tired with for-loop. I initialized variable "i" to -2 (i=-2) I would get the year drop down list from 2003 but, by default 2003 would come.
    So, i posted the question.
    I tried your code. It is giving following error.
    A Servlet Exception Has Occurred
    org.apache.jasper.JasperException: Unable to compile class for JSP
    An error occured between lines: 122 and 127 in the jsp file: /test/inpt.jsp
    Generated servlet error:
    C:\Program Files\Apache Tomcat 4.0\work\localhost\general\test\inpt$jsp.java:182: Invalid type expression.
    first.set(Calendar.YEAR, 2003)
    ^
    An error occured between lines: 127 and 131 in the jsp file: /test/inpt.jsp
    Generated servlet error:
    C:\Program Files\Apache Tomcat 4.0\work\localhost\general\test\inpt$jsp.java:186: Invalid declaration.
    out.write("\r\n \r\nYear : \r\n \r\n"); ^ An error occured between lines: 198 and 203 in the jsp file: /test/inpt.jsp Generated servlet error: C:\Program Files\Apache Tomcat 4.0\work\localhost\general\test\inpt$jsp.java:282: Invalid type expression. first1.set(Calendar.YEAR, 2003) ^ An error occured between lines: 203 and 207 in the jsp file: /test/inpt.jsp Generated servlet error: C:\Program Files\Apache Tomcat 4.0\work\localhost\general\test\inpt$jsp.java:286: Invalid declaration. out.write("\r\n \r\nYear :\r\n \r\n");
    ^
    4 errors
    Pls. Help.
    Regards,
    Ashu

  • To Display "Calendar Month/Year" at report level from Calendar Day

    Hello Friends,
    I have a scenario in which I have 0CALDAY (e.g. 01.01.2009) along with other fields available in my report. My requirement is to display "Calendar Month/Year" (e.g. 01.2009) in my report.
    Is it possible to have "Calendar Month/Year" in my report from 0CALDAY, by making changes to the query, as I cannot remodel the underlying InfoCube?
    Many Thanks,
    VishwA

    HI Vishwa,
    Hope it will helps.
    How to get month from CREATE DATE field??
    Regards,
    SVS

  • IPhone will not display calendar items more than one day in advance.

    iPhone will not display calendar items more than one day in advance. 
    I used to have a droid and loved the calendar on the main screen that used to show me the next few appointments coming up - so far I have only figured out how to put in to show for next day or 2 days or etc....
    is there any way to show tomorrow and next few days in notification, or is there a good app out there that will greet me. dont have 4s to ask just a 4
    i used google calendar and they all show up in calendar but REALLY need the functionality to see what is coming up, kind of like what you see in outlook or any other email program.
    please help out this noob.

    Is this what you're doing:
    OS X Yosemite: Recover your entire system

  • How to display system date by default

    Hi,
    Please tell me how to display the default date as system date in a text box, and it should also allow me to select the date from the calendar and update.
    i tried to give'select sysdate from dual' but it dint work.
    Please help me..
    Regards,
    Pallavi

    I'm not sure what you mean.
    sysdate retrieves the current date when the script is executed (eg. when you run the report).
    Do you mean that after you change the date value in the report and submit the page, it changes back to sysdate, instead of the date you selected?
    This would be caused by an incorrect setting in the "Source Used" field.
    eg. use "Only when current value in session state is null"
    instead of "Always, replacing any existing value in the session state"

  • MAX: How to display icons (blob) in VB

    Hi!
    I've written a VB application which gets some information from MAX. It works very well, but I was wondering how to display the icons (stored as blob). Who can help me? Thank you in advance!!
    here is a piece of my code:
    Dim maxConf As mxConfiguration
    Dim maxItems As mxItems
    Dim maxItemAttribute As ImxItemAttribute
    Set maxConf = New MXCTRLLib.mxConfiguration
    maxConf.Initialize ("Local")
    Set maxItems = maxConf.EnumItems("CAT=Software,ALL")
    Set maxItemAttribute = maxItems.Item(ItemsListBox.ListIndex).EnumItemAttributes.Item(AttributesListBox.ListIndex)
    Select Case maxItemAttribute.AttributeType
    Case "Blob"
    'here, I want to display the icon and I need your help!
    Case Else
    ListBox1.AddItem (maxItemAttribute.AttributeValue)
    end select

    I will try this when I get back home - travelling at the moment.
    A bit more background....... I have a Function that is called to produce a yearly calendar view of rentals for a home, along with the rental prices - this has already been written using the as_pdf3 package, which can either physically create the report on the server (using utl_file), or it can return the blob direct.
    On the screen, the user can select the years that they wish to see in the report, push a button which will pass the parameters into the above said function, and then launch the "blob" in another window (as the blob is PDF format, it would launch the users PDF reader) - if the user then wants to save the report, they can do (using PDF reader) - this avoids me a) saving and housekeeping a file(s) on the server, b) I don't have to enable utl_file for the schema

  • ICal: How to recover calendars after a hard drive crash

    Had a messy crash of Tiger system, installed Leopard on a new hard disk. I eventually salvaged the old disk, but not before I had started using iCal on the new system. I'm trying to sort out how to display the calendar information that was in the old system at the time of the crash. I'm hoping someone can confirm a few things.
    On the Tiger system, it appears that the calendar data was probably stored in :
    Home/Library/Application Support/iCal. There is a file called nodes.plist and a folder called Sources. The Sources folder appears to hold the calendar information - yes? Is the nodes.plist file important? I hadn't been syncing or using the ToDo list, so I'm assuming I don't need to worry about those - yes?
    Looking at the Leopard installation, it appears that the same information is now located at:
    Home/Library/Calendars - yes?
    If I copy the Tiger data into the Leopard installation, will it run? DIfferences in file format? What am I up against? I don't have the Tiger installation from which to export calendars any longer.
    Thanks for any wisdom anyone can pass along ...
    Message was edited by: Roger Diggle

    open ical and go to file>import, choose the option "import an ical file" and then point to the path homefolder/library/application support/ical/sources from your old disk, and for each folder which represents a calendar, in that folder, select the .ics file.. then import. you should have the calendar imported in ical.
    hope this helps

  • How to display hijri date..

    hi everyone!
    can someone tell how to convert georgian date into hijri date...
    and if the date is some old date....
    thanks and regards
    Tariq.

    Here are a few things you might need to know.
    1.How to set Calendar to "Arabic Hijrah" ?
    2.How to display both Hijrah and Gregorian dates in the same select statement?
    3.What is Calendar Deviation?
    4.How to set deviation?
    Questions & Answers
    1.How to set Calendar to "Arabic Hijrah" ?
    Answer
    Set NLS_CALENDAR parameter in one of the following ways:
    1. In the Current session :
    SQL> alter session set NLS_CALENDAR="Arabic Hijrah" ;
    2. All applications for a specific client:
    Set NLS_CALENDAR Variable in client OS environment.
    <e.g: On NT: set variable in the registry
    On Unix: set UNIX environment variable in .profile/.cshrc>
    3. Within SQL function:
    SQL> select to_char(sysdate,'day dd month yyyy','nls_calendar=''arabic hijrah''')
    from dual ;
    References
    <Note:30772.1>
    2.How to display both Hijrah and Gregorian dates in the same select statement?
    Answer
    select
    to_char(sysdate,'day dd month yyyy','nls_calendar=''arabic hijrah'''),
    to_char(sysdate,'day dd month yyyy','nls_calendar=''gregorian''')
    from dual ;
    References
    <bug:1302683>
    3.What is Calendar Deviation?
    Answer
    Since Hijrah month is based on the moon complete revolution around the sun, Hijrah
    Calendar has different number of days in a year than Gregorian; therefore some manual
    deviation adjustement might be needed for the conversion to/from Gregorian. In other
    words HIJRAH calendar is Lunar based, corrections need to be made every so often.
    4.How to set deviation?
    Answer
    1. Shutdown the database
    2. Edit lxecal.nlt (lxecal.dat in Oracle7) in $ORACLE_HOME/ocommon/nls.
    e.g: to add one day after Sep-29-2000:
    DEFINE calendar
    calendar_name = "Arabic Hijrah"
    DEFINE calendar_deviation
    deviation_data = {
    <"Sep-29-2000 ad">:1
    ENDDEFINE calendar_deviation
    ENDDEFINE calendar
    Note: Gregorian date specified in the deviation should correspond to one of
    29th, 30th or 31th days of the hijrah calendar.
    3. Run the NLS Calendar Utility lxegen to register your modification to Oracle calendar
    system, this utility generates lxecalah.nlb file in the same directory mentioned above.
    4. startup the database.
    The same procedure can be followed to subtract days, but number specified in the
    deviation_data should be greater than 10.
    <e.g: 11 --> subtract one day, 12 --> subtract two days ...etc>
    References
    Hope this helps
    Regards
    Grant Ronald
    Forms Product Management

Maybe you are looking for

  • Form Personalization - Custom Function - How to pass parameters?

    Hi, My requirement is to call a custom mod pl/sql program (html page) from purchasing when the "approve" button is pressed. I have it working, but don't know how to pass parameters to my function. I have my function defined and registered. In the def

  • IView error in MSS

    Hi Everyone, I run the MSS iviews for employee viewer and they return this error: An exception occurred while processing a request for : iView : pcd:portal_content/com.debeers.fld.content/zpor_sysfldrCanada/com.debeers.roles.roles/com.debeers.zpor_fl

  • Header in Viewer

    Hi, I created a crosstab in viewer with say "Category" in the top and "Collection" in left. I cant see these headers for the axes, I mean I can see the different values of Collection (A1, A2...) and Category(C1, c2,...), but the axis header/title ("C

  • AUXILIARY database update using full backup from target database

    Hi, I am now facing the problem with how to implement AUXILIARY database update to be consistent with the target database during a certain period (a week). I did a fully backup on our target database everyday using rman. I know it is possible to use

  • Set Photoshop CS6 as default

    I have lots of JPG files that are"sort of one-of. All I need to do is open, crop, and print. I am trying to set Photoshop CS6 as the default for opening JPG files. I got through the "Open with" process to specify C:/Program Files/Adobe/Adobe Photosho