Complete this code in main to perform the requested operations for a date entered by the user in this format: month dd, yyyy

public static void main( String [] args )

{

Scanner scan = new Scanner( System.in );

System.out.print( "Enter a date > " );

String date = scan.nextLine( );

// a. output the first letter in the month

// b. output the date in all lowercase letters

Respuesta :

Answer:

a) System.out.println(date.charAt(0));

b)System. out.println(date.toLowerCase() );

Explanation:

a) The first letter of the string is found at the index 0. A character in the String can be extracted using the String method called charAt( ) which takes the index of the character in the String as an argument. To print it out, we use the println method. That is:

System.out.println(date.charAt(0) );

b) To covert a String to lowercase, we use the toLowerCase method.

System.out.println(date.toLowerCase() );

ACCESS MORE
EDU ACCESS