I am writing a code that takes the user input year and month and prints out a calendar of the specific month based off of the given month. It uses loops to make the printout possible.
This is the desired output
Enter a year: 2013
Enter a month (1-12): 2
February 2013
----------------------------------------
sun mon tue wed thrus 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
The thing with my code that I looked online on how to print an entire calendar (Jan to Dec full year) but I was wondering if there is a way to shorten the entire printout to just a selected month from the user. I did look at this question as a reference and found it quite helpful but the answers all print the entire year. How to display calendar in java
What I believe should be changed about the program is that for the months there should be for loops and parts of the code determining if the year is a leap year or not. I think there should be an array for the selection of months and whichever one that is there will print out in the middle of the section.