CIS-2271 Homework #2: Splitting Dates

Due: Tuesday, September 3, 2013

Read section 2.5 and start reading chapter 3 in the text.

  1. Write a program that accepts a date in the format YYYY-MM-DD and displays the year, month, and day separately. Your program should read a string from the user and then split it into pieces using appropriate string methods. It should then convert the resulting strings into integers using Integer.parseInt(). For example:

              Enter a date: 2013-09-03
              Year  = 2013
              Month = 9
              Day   = 3
            

    Notice there is no leading zero on the displayed value of the month or day. This is because they are being printed as integers and not as the strings such as "09" or "03."

  2. Modify your program to accept a string consisting of an event description followed by a due date in the format: EVENT-DESCRIPTION::DATE. The program should display the event description and components of the date separately. For example:

              Enter Event: Finish CIS-2271 homework::2013-09-03
              Event = Finish CIS-2271 homework
              Year  = 2013
              Month = 9
              Day   = 3
            

Last Revised: 2013-08-26
© Copyright 2013 by Peter C. Chapin <PChapin@vtc.vsc.edu>