475
(Hint:Use nested switchstatements, where the outer statement uses the first
letter of the abbreviation as its switch expression.)
2.Design and write a Java application that reads a date in numeric form from a
set of three fields and displays it in English within a label. Use appropriate but-
tons. For example:
Given the date:
10 27 1942
The application displays:
October twenty-seventh, nineteen hundred forty-two.
Here is another example:
Given the date:
12 10 2010
The application displays:
December tenth, two thousand ten.
The application should display an error message for any invalid date, such as 2
29 1883(1883 wasn’t a leap year).
3.Write a Java application that reads full names from an input file and writes the
initials for the names to an output file named initials. For example, the input
John James Henry
should produce the output
JJH
The names are stored in the input file as first name, middle name, last name,
with each name separated by an arbitrary number of blanks. Only one name
appears per line. The first name or the middle name could be just an initial, or
there may not be a middle name.
4.Write a Java application that converts letters of the alphabet into their
corresponding digits on the telephone. The application should let the user en-
ter letters repeatedly until a “Q” or a “Z” is entered. (Qand Zare the two letters
that are not on the telephone.) An error message should be printed for any
nonalphabetic character that is entered.
The letters and digits on the telephone have the following correspondence:
ABC = 2 DEF = 3 GHI = 4
JKL = 5 MNO = 6 PRS = 7
TUV=8 WXY =9