Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Java only Write a program that reads a sentence and then prints a diamond shaped tree for every word in the sentence. As an example,
Java only
Write a program that reads a sentence and then prints a diamond shaped tree for every word in the sentence. As an example, if the string has the value "sample text", then the program should print the pattern (as shown, in capitals for each word) Save As Assign21 Enter a Sentence: sample text \begin{tabular}{l|l} \multicolumn{1}{c}{ S } & Note: The split function can be used \\ SAS & to separate the words in the \\ SAMAS & sentence. \\ SAMPMAS & String words[]; \\ SAMPLPMAS & \\ SAMPLELPMAS & words=sentence.split(" "); \\ SAMPLPMAS & This will place each word into an array \\ SAMPMAS & based on a space. \\ SAMAS & \\ SAS & \\ S & \\ A & \\ P & \\ L & \\ E & \\ T & \end{tabular} The program should work for any string of any sizeStep 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