Problem: Today you are to write a Java program that will prompt for and read 1 word of a length greater that 3 entered by the user, which you store in a String variable. With the use of loops and nested loops you are to produce a specific triangular pattern with the characters of the word without the first and last characters and having: & next to each character as illustrated in the figures below, exactly as displayed in the samples below. Your code must work no matter what word the user enters. You can use the appropriate combination of loops and nested loops to solve the problem. You are not allowed to use arrays. Based on the previous specifications your program should behave and look exactly as shown in the cases below. Your program should work for any word entered by the user, not just the ones in the samples. Note that in the output: • is a space, → is a tab and J is a new line. All words except for user input (in bleu) must be exactly as indicated in the sample outputs. Any extra "spaces" and/or "new lines" will be graded a wrong answer. Program Sample outputs Enter-a word: Roman. o&>m&>a&→. m&>a&>J a&>J Pretty triangle! Enter-a word:9876543.J 8&>78>6&→5&→4&J 78>6&>5&→4&J 6&→5&→4&J 5&→4&J Prettyotriangle! Enter-a word: mOntreAlJ 0&>n&>t&>r&→e&→A&→J n&>t&>r&>e&→A&→J t&>r&>e&>A&→J r&→e&→A&> e&>A&>J A&→J

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter7: User-defined Simple Data Types, Namespaces, And The String Type
Section: Chapter Questions
Problem 3PE
icon
Related questions
Question
Problem: Today you are to write a Java program that will prompt for and read 1 word of a length greater that 3 entered by
the user, which you store in a String variable. With the use of loops and nested loops you are to produce a specific triangular
pattern with the characters of the word without the first and last characters and having: & next to each character as
illustrated in the figures below, exactly as displayed in the samples below. Your code must work no matter what word the
user enters.
You can use the appropriate combination of loops and nested loops to solve the problem. You are not allowed to use arrays.
Based on the previous specifications your program should behave and look exactly as shown in the cases below. Your
program should work for any word entered by the user, not just the ones in the samples.
Note that in the output: • is a space, → is a tab and J is a new line. All words except for user input (in bleu) must be exactly
as indicated in the sample outputs. Any extra "spaces" and/or "new lines" will be graded a wrong answer.
Program Sample outputs
Enter-a word: Roman.
o&>m&>a&→.
m&>a&>J
a&>J
Pretty triangle!
Enter-a word:9876543.J
8&>78>6&→5&→4&J
78>6&>5&→4&J
6&→5&→4&J
5&→4&J
Prettyotriangle!
Enter-a word: mOntreAlJ
0&>n&>t&>r&→e&→A&→J
n&>t&>r&>e&→A&→J
t&>r&>e&>A&→J
r&>e&>A&>.
e&>A&>J
A&>J
Pretty triangle!
Note 1: You are to expect a perfect user who will always enter a word of a length greater than 3 (with no whitespace
characters); hence do not verify the validity of user input.
Note 2: The use of libraries other than java.util.Scanner is prohibited. Your program must work for any strings entered, not
just the ones in the samples above.
Note 3: Final thought, remember that your solution is case-sensitive and space-sensitive and fulfill the above instructions
carefully and precisely.
Transcribed Image Text:Problem: Today you are to write a Java program that will prompt for and read 1 word of a length greater that 3 entered by the user, which you store in a String variable. With the use of loops and nested loops you are to produce a specific triangular pattern with the characters of the word without the first and last characters and having: & next to each character as illustrated in the figures below, exactly as displayed in the samples below. Your code must work no matter what word the user enters. You can use the appropriate combination of loops and nested loops to solve the problem. You are not allowed to use arrays. Based on the previous specifications your program should behave and look exactly as shown in the cases below. Your program should work for any word entered by the user, not just the ones in the samples. Note that in the output: • is a space, → is a tab and J is a new line. All words except for user input (in bleu) must be exactly as indicated in the sample outputs. Any extra "spaces" and/or "new lines" will be graded a wrong answer. Program Sample outputs Enter-a word: Roman. o&>m&>a&→. m&>a&>J a&>J Pretty triangle! Enter-a word:9876543.J 8&>78>6&→5&→4&J 78>6&>5&→4&J 6&→5&→4&J 5&→4&J Prettyotriangle! Enter-a word: mOntreAlJ 0&>n&>t&>r&→e&→A&→J n&>t&>r&>e&→A&→J t&>r&>e&>A&→J r&>e&>A&>. e&>A&>J A&>J Pretty triangle! Note 1: You are to expect a perfect user who will always enter a word of a length greater than 3 (with no whitespace characters); hence do not verify the validity of user input. Note 2: The use of libraries other than java.util.Scanner is prohibited. Your program must work for any strings entered, not just the ones in the samples above. Note 3: Final thought, remember that your solution is case-sensitive and space-sensitive and fulfill the above instructions carefully and precisely.
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Types of Loop
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Systems Architecture
Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning