Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For the solution, use the StarPattern class you added to the project. That is, public class StarPattern { public static void main(String[] args) { //

image text in transcribed

For the solution, use the StarPattern class you added to the project. That is,

  1.  public class StarPattern { 
     public static void main(String[] args) { // TODO Auto-generated method stub 

    } }

  2. In the body of the main method, declare a single String class type variable named pattern.

  3. The pattern will hold the address of a String object with a string literal as its value, which is needed to be created in 4.

  4. The string value is a description of the star pattern given in 1. Write this description using the *, the space character, and (new line character) as many times as needed as a string value.

  5. (a) Use String class length method to print the length of the obtained pattern in 4. The length of this pattern is the total number of the characters used in constructing this pattern.

  6. (b) Then print the star pattern from the string value which is constructed in 4. Use a single print statement that prints pattern to the console; that is, you are not allowed to use System.out.println repeatedly to print the given star pattern line by line. The result of this print statement will display a star pattern as shown in 1.

  1. Use JOptionPane class showMessageDialog method to complete the same tasks as 5 above. Display the length of the pattern and the star pattern, as shown in Figure 3. When you use JOptionPane class, you are required to have the following import for JOptionPane class to be placed before the comment block of 3. in the Preliminaries section.

    import javax.swing.JOptionPane; //required for JOptionPane class. Before the end of the main method, you are required to have System.exit(0); //required for JOptionPane class.

  2. Run your program to see if the pattern appears correctly. Remove errors and make corrections as necessary in 4. That means, you must have the correct number of the occurrences for the *s with spaces and s in a string literal. Repeat this until you have the star pattern displayed correctly to both the console and then the message dialog boxes.

1. Rather than the pattern of the book, you must create the modified star pattern as shown in Figure 1: CS 16000-01 - 02/03/04, Spring Semester 2020 * * * * * * * * * * * * * * * * Figure 1 1. Rather than the pattern of the book, you must create the modified star pattern as shown in Figure 1: CS 16000-01 - 02/03/04, Spring Semester 2020 * * * * * * * * * * * * * * * * Figure 1

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_2

Step: 3

blur-text-image_3

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

Data Management Databases And Organizations

Authors: Richard T. Watson

3rd Edition

0471418455, 978-0471418450

More Books

Students also viewed these Databases questions

Question

Name five common report formats.

Answered: 1 week ago

Question

List the advantages and disadvantages of the pay programs. page 505

Answered: 1 week ago