0% found this document useful (0 votes)
342 views2 pages

COMP 248 Lab Exercise 5.1 - H - I - L Due Date

The document provides instructions for a lab exercise to write a program that accepts a single word input from the user and displays it in a triangular pattern using tabs and newlines. The program must work for any one word string input without validating the input. It provides two examples of expected output for the input words "COMP248" and "test". It notes some string methods that may be useful and restrictions on using additional libraries beyond Scanner. It reminds the student to submit without a package statement.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
342 views2 pages

COMP 248 Lab Exercise 5.1 - H - I - L Due Date

The document provides instructions for a lab exercise to write a program that accepts a single word input from the user and displays it in a triangular pattern using tabs and newlines. The program must work for any one word string input without validating the input. It provides two examples of expected output for the input words "COMP248" and "test". It notes some string methods that may be useful and restrictions on using additional libraries beyond Scanner. It reminds the student to submit without a package statement.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Lab Exercise 5.

1_H_I_L COMP 248

Due date: Today, at the end of the lab period.

Read this entire document before beginning your lab.


Make sure to locate and place the PC2 Lab System on your desktop. The Comp248_Lab_Manual file is available on the H:
drive if you don’t remember how to use the system, you should worry about this after completing the question.
For this lab you are required to fulfill all requirements exactly as described in this provided document, no less, no more.

Today you are commissioned to write a program that will accept a single word from a 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 as
illustrated in the figures below.
So after initializing your variables, you are to retrieve a single word String input from the user and then find the
appropriate combination of for loops to display each character exactly as displayed in the two samples below. Your code
must work no matter what word the user enters.
Based on the previous specifications your program should look and behave exactly as displayed in the cases below:
REMEMBER in the output: ◦ is a space,  is a new line and  is a tab. Text in green is user
input.

Enter◦a◦string:◦COMP248 Enter◦a◦string:◦test
 
8  t 
8 4  t s 
8 4 2  t s e 
8 4 2 P  t s e t 
8 4 2 P M  t s e 
8 4 2 P M O  t s 
8 4 2 P M O C  t
8 4 2 P M O 
8 4 2 P M 
8 4 2 P 
8 4 2 
8 4 
8

Note:
1. String methods you may find useful are length(), charAt() and/or substring().
2. When displaying the triangle, the space between each character is exactly equivalent to 1 tab in java; in other
words, each character is followed by one tab including the last character on each line.
3. You may need more than one nested loop to solve the problem.
4. You are to expect a perfect user who will always enter a valid one-word string; that is, do not verify the validity of
the user input.
5. The use of libraries other than java.util.Scanner is prohibited.
6. Final thought, remember that your solution is case-sensitive and space-sensitive.
Reminder:
When submitting your solution to the lab system, make sure there is no package statement at
the top of your .java file as this will result in a grade of 0 (restriction of this system).

You might also like