Answered step by step
Verified Expert Solution
Link Copied!

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,

image text in transcribedJava 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 size

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Essential SQLAlchemy Mapping Python To Databases

Authors: Myers, Jason Myers

2nd Edition

1491916567, 9781491916568

More Books

Students also viewed these Databases questions

Question

Write the formula for each compound. nitrogen trioxide

Answered: 1 week ago