©May not be copied or duplicated
without the permission of the owner
Dr. Nora Houari
Lab#5 Exercise
COMP 248
Due date: Today, at the end of the lab period.
Read this entire document before beginning your lab.
For this lab you are required to fulfill all requirements exactly as described in this provided document, no less, no more.
Problem: Today you are to write a Java program that will prompt for and read 1 word of length greater than 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 pattern with
the characters of the word without first and last characters as illustrated exactly 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 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:◦NORA
R→
R→O→
R→
Cool◦shape!
Enter◦a◦word:◦Crystal
Enter◦a◦word:◦14785296
a→
a→t→
a→t→s→
a→t→s→y→
a→t→s→y→r→
a→t→s→y→
a→t→s→
a→t→
a→
Cool◦shape!
9→
9→2→
9→2→5→
9→2→5→8→
9→2→5→8→7
9→2→5→8→7→ 4
9→2→5→8→7→
9→2→5→8→
9→2→5
9→2
9→
Cool◦shape!
Note 1: You are to expect a perfect user who will always enter a word of 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.