Problem

In the formatting examples from the chapter, we always provided a fixed control string,...

In the formatting examples from the chapter, we always provided a fixed control string, such as

System.out.format("%4d", 23);

It is possible, however, to dynamically create the control string, as in

int i = 4;

System.out.format("%" + i + "d", 23);

Using this idea of dynamically creating a control string, write a code fragment that outputs 50 X’s, using a separate line for each X. An X on a single line is preceded by two more leading spaces than the X on the previous line. The following figure shows the output for the first five lines.

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 6