Question
Write a java program that has a user input a sentence. Each word in that sentence will be tokenized. If the first letter of the
Write a java program that has a user input a sentence. Each word in that sentence will be tokenized. If the first letter of the word is an 'a', it prints out that word + "yay". If the word begins with any other letter it removes the first letter and places it at the end of the word and adds "ay" to it.
So the sample code for one word is below. I need the program to do this for each word in the sentence. Thanks!
char first = input.charAt(0); if (first == 'a') System.out.println(input + "yay"); else System.out.println(input.substring(1) + first + "ay");
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started