- Write a program that prompts the user enter a word, anddetermines the first half and second half of the word. Print thefirst and second half of the word on different lines. Sample runsof the program are shown below. Note: If the word is an odd numberof letters, the first half should contain fewer letters (as shownin sample run #2)
SAMPLE PROGRAM RUN#1Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â
Enter a word: carrot
First half: car
Second half: rot
SAMPLE PROGRAM RUN#2Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â
Enter a word: plant
First half: pl
Second half: ant
Complete your answer by typing code below
import java.util.Scanner;
public class WordHalves
{
public static void main(String[] args)
{
Scanner reader = new Scanner(System.in);
System.out.print(\"Enter a word: \");
String word = reader.nextLine();
}
}