McKeever+Java+Code


 * This is my final project code. I took the month abbreviation calculator and advanced it. I made it say the full month, as well as the number day in that month, and what day of the week it is. I also instituted the .trim function.**

/**MonthAbbreviations.java reads a number from 1-365 and displays


 * the corresponding day of the month and the day of the week.



import java.util.Scanner; public class MonthCalculator {

public static void main(String[] args) {

//get the day number

System.out.println("To see a day of the year 2011,");

System.out.print(" enter a day number (1-365): ");

//tells the user to input a day of the year

Scanner keyboard = new Scanner(System.in);

//uses keyboard for input to give the day of a given month an dthe day of the week

int dayNumber = keyboard.nextInt;

//compute the day of the month and day of the weekday.

final String DATE_TABLE =

//table of ALL of the days of the year 2011

"Saturday, January-1 Sunday, January-2 Monday, January-3 Tuesday, January-4 Wednesday, January-5 Thursday, January-6 Friday, January-7 Saturday, January-8 Sunday, January-9 Monday, January-10 Tuesday, Januray-11 Wednesday, January-12 Thursday, Januray-13 Friday, Januray-14 Saturday, January-15 Sunday, Januray-16 Monday, January-17 Tuesday, Januray-18 Wednesday, January-19 Thursday, January-20 Friday, January-21 Saturday, January-22 Sunday, January-23 Monday, January-24 Tuesday, January-25 Wednesday, January-26 Thursday, January-27 Friday, January-28 Saturday, January-29 Sunday, January-30 Monday, January-31 " +

"Tuesday, February-1 Wednesday, February-2 Thursday, February-3 Friday, February-4 Saturday, February-5 Sunday, February-6 Monday, February-7 Tuesday, February-8 Wednesday, February-9 Thursday, February-10 Friday, February-11 Saturday, February-12 Sunday, February-13 Monday, February-14 Tuesday, February-15 Wednesday, February-16 Thursday, February-17 Friday, February-18 Saturday, February-19 Sunday, February-20 Monday, February-21 Tuesday, February-22 Wednesday, February-23 Thursday, February-24 Friday, February-25 Saturday, February-26 Sunday, February-27 Monday, February-28 " +

"Tuesday, March-1 Wednesday, March-2 Thursday, March-3 Friday, March-4 Saturday, March-5 Sunday, March-6 Monday, March-7 Tuesday, March-8 Wednesday, March-9 Thursday, March-10 Friday, March-11 Saturday, March-12 Sunday, March-13 Monday, March-14 Tuesday, March-15 Wednesday, March-16 Thursday, March-17 Friday, March-18 SaturdayMarch-19 Sunday, March-20 Monday, March-21 Tuesday, March-22 Wednesday, March-23 Thursday, March-24 Friday, March-25 Saturday, March-26 Sunday, March-27 Monday, March-28 Tuesday, Macrh-29 Wednesday, March-30 Thursday, March-31 " +

"Friday, April-1 Saturday, April-2 Sunday, April-3 Monday, April-4 Tuesday, April-5 Wednesday, April-6 Thursday, April-7 Friday, April-8 Saturday, April-9 Sunday, April-10 Monday, April-11 Tuesday, April-12 Wednesday, April-13 Thursday, April-14 Friday, April-15 Saturday, April-16 Sunday, April-17 Monday, April-18 Tuesday, April-19 Wednesday, April-20 Thursday, April-21 Friday, April-22 Saturday, April-23 Sunday, April-24 Monday, April-25 Tuesday, April-26 Wednesday, April-27 Thursday, April-28 Friday, April-29 Saturday, April-30 " +

"Sunday, May-1 Monday, May-2 Tuesday, May-3 Wednesday, May-4 Thursday, May-5 Friday, May-6 Saturday, May-7 Sunday, May-8 Monday, May-9 Tuesday, May-10 Wednesday, May-11 Thursday, May-12 Friday, May-13 Saturday, May-14 Sunday, May-15 Monday, May-16 Tuesday, May-17 Wednesday, May-18 Thursday, May-19 Friday, May-20 Saturday, May-21 Sunday, May-22 Monday, May-23 Tuesday, May-24 Wednesday, May-25 Thursday, May-26 Friday, May-27 Saturday, May-28 Sunday, May-29 Monday, May-30 Tuesday, May-31 " +

"Wednesday, June-1 Thursday, June-2 Friday, June-3 Saturday, June-4 Sunday, June-5 Monday, June-6 Tuesday, June-7 Wednesday, June-8 Thursday, June-9 Friday, June-10 Saturday, June-11 Sunday, June-12 Monday, June-13 Tuesday, June-14 Wednesday, June-15 Thursday, June-16 Friday, June-17 Saturday, June-18 Sunday, June-19 Monday, June-20 Tuesday, June-21 Wednesday, June-22 Thursday, June-23 Friday, June-24 Saturday, June-25 Sunday, June-26 Monday, June-27 Tuesday, June-28 Wednesday, June-29 Thursday, June-30 " +

"Friday, July-1 Saturday, July-2 Sunday, July-3 Monday, July-4 Tuesday, July-5 Wednesday, July-6 Thursday, July-7 Friday, July-8 Saturday, July-9 Sunday, July-10 Monday, July-11 Tuesday, July-12 Wednesday, July-13 Thursday, July-14 Friday, July-15 Saturday, July-16 Sunday, July-17 Monday, July-18 Tuesday, July-19 Wednesday, July-20 Thursday, July-21 Friday, July-22 Saturday, July-23 Sunday, July-24 Monday, July-25 Tuesday, July-26 Wednesday, July-27 Thursday, July-28 Friday, July-29 Saturday, July-30 Sunday July-31 " +

"Monday, August-1 Tuesday, August-2 Wednesday, August-3 Thursday, August-4 Friday, August-5 Saturday, August-6 Sunday, August-7 Monday, August-8 Tuesday, August-9 Wednesday, August-10 Thursday, August-11 Friday, August-12 Saturday, August-13 Sunday, August-14 Monday, August-15 Tuesday, August-16 Wednesday, August-17 Tuesday, August-18 Wednesday, August-19 Thursday, August-20 Friday, August-21 Saturday, August-22 Sunday, August-23 Monday, August-24 Tuesday, August-25 Wednesday, August-26 Thursday, August-17 Friday, August-28 Saturday, August-29 Sunday, August-30 Monday, August-31 " +

"Thursday, September-1 Friday, September-2 Saturday, September-3 Sunday, September-4 Monday, September-5 Tuesday, September-6 Wednesday, September-7 Thursday, September-8 Friday, September-9 Saturday, September-10 Sunday, September-11 Monday, September-12 Tuesday, September-13 Wednesday, September-14 Thursday, September-15 Friday, September-16 Saturday, September-17 Sunday, September-18 Monday, September-19 Tuesday, September-20 Wednesday, September-21 Thursday, September-22 Friday, September-23 Saturday, September-24 Sunday, September-25 Monday, September-26 Tuesday, September-27 Wednesday, September-28 Thursday, September-29 Friday, September-30 " +

"Saturday, October-1 Sunday, October-2 Monday, October-3 Tuesday, October-4 Wednesday, October-5 Thursday, October-6 Friday, October-7 Saturday, October-8 Sunday, October-9 Monday, October-10 Tuesday, October-11 Wednesday, October-12 Thursday, October-13 Friday, October-14 Saturday, October-15 Sunday, October-16 Monday, October-17 Tuesday, October-18 Wednesday, October-19 Thursday, October-20 Friday, October-21 Saturday, October-22 Sunday, October-23 Monday, October-24 Tuesday, October-25 Wednesday, October-26 Thursday, October-27 Friday, October-28 Saturday, October-29 Sunday, October-30 Monday, October-31 " +

"Tuesday, November-1 Wednesday, November-2 Thursday, November-3 Friday, November-4 Saturday, November-5 Sunday, November-6 Monday, November-7 Tuesday, November-8 Wednesday, November-9 Thursday, November-10 Friday, November-11 Saturday, November-12 Sunday, November-13 Monday, November-14 Tuesday, November-15 Wednesday, November-16 Thursday, November-17 Friday, November-18 Saturday, November-19 Sunday, November-20 Monday, November-21 Tuesday, November-22 Wednesday, November-23 Thursday, November-24 Friday, November-25 Saturday, November-26 Sunday, November-27 Monday, November-28 Tuesday, November-29 Wednesday, November-30 " +

"Thursday, December-1 Friday, December-2 Saturday, December-3 Sunday, December-4 Monday, December-5 Tuesday, December-6 Wednesday, December-7 Thursday, December-8 Friday, December-9 Saturday, December-10 Sunday, December-11 Monday, December-12 Tuesday, December-13 Wednesday, December-14 Thursday, December-15 Friday, December-16 Saturday, December-17 Sunday, December-18 Monday, Devember-19 Tuesday, December-20 Wednesday, December-21 Thursday, December-22 Friday, December-23 Saturday, December-24 Sunday, December-25 Monday, December-26 Tuesday, December-27 Wednesday, December-28 Thursday, December-29 Friday, December-30 Saturday, December-31 ";

int start = (dayNumber - 1) * 24;

int stop = start + 24;

String dayName = DATE_TABLE.substring(start, stop);

System.out.println("\nDay #" + dayNumber +

" is '" + dayName.trim + "'.");

//display the date and day of the week

} }