Problem

Nesting Loops In this lab, you add nested loops to a Java program provided with the da...

Nesting Loops

In this lab, you add nested loops to a Java program provided with the data files for this book. The program should print the letter E, as shown in Figure 5-2. The letter E is printed using asterisks, three across and five down. Note that this program uses System. Out.print("*") ; to print an asterisk without a new line.

1. Open the source code file named LetterE.java using Notepad or the text editor of your choice.

2. Write the nested loops to control the number of rows and the number of columns that make up the letter E.

3. In the loop body, use a nested if statement to decide when to print an asterisk and when to print a space. The output statements have been written, but you must decide when and where to use them.

4. Save this source code file in a directory of your choice, and then make that directory your working directory.

5. Compile the source code file, LetterE.java.

6. Execute the program. Your letter E should look like the letter E in Figure 5-2.

7. Modify the program to change the number of rows from five to seven and the number of columns from three to five. What does the letter E look like now?

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 5
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT