Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Due Date: Thursday March 8,2018 (by midnight) Weight: 2 points Obiectives: Neste

ID: 3724768 • Letter: D

Question

Due Date: Thursday March 8,2018 (by midnight) Weight: 2 points Obiectives: Nested Control Statements (chapter 5) Using Notepad, JCreator or your preferred IDE, create a Java application in a class named Triangles.java. The purpose of this application is to display the foura triangular patterns on the right separately, one below the other Use for loops to generate the patterns. All asterisks () should be printed by a single statement of the form System.out.print( "*" which causes the asterisks to print side by side A statement of the form System.out.println): can be used to move to the next ne. A statement of the form System.out.print " can be used to display a space for the last two patterns. There should be no other output statements in the program. The above three print statements are the only ones allowed print statements. Le.you must print one asterisk at a time, one blank at a time, and one new line at a time. Submit a zip file into Lab 9 Drop Box that contains: Your Java source code (do not include class files) Screenshot of your output (System.out) showing all the four triangular patterns In order to help you get started, the starter code on the following page displays the first and the third patterns, so your task is to understand the given code and complete the missing parts, which display the second and fourth triangles 9099

Explanation / Answer

Triangles.java

public class Triangles {

public static void main(String[] args) {
int row;
int column;
int space;
int numLines = 10;
//Displaying the first Triangle
for (row = 1; row <= numLines; row++) {
for (column = 1; column <= row; column++) {
System.out.print("*");
}
System.out.println();
}

System.out.println();

//displaying the second triangle
for (row = numLines; row >= 1; row--) {
for (column = 1; column <= row; column++) {
System.out.print('*');
}
System.out.println();
}

System.out.println();

//Displaying the third Triangle
for (row = numLines; row >= 1; row--) {
for (space = numLines; space > row; space--) {
System.out.print(" ");
}
for (column = 1; column <= row; column++) {
System.out.print('*');
}
System.out.println();
}

System.out.println();

//Displaying the fouth Triangle
for (row = 1; row <= numLines; row++) {
for (space = numLines; space > row; space--) {
System.out.print(" ");
}
for (column = 1; column <= row; column++) {
System.out.print('*');
}
System.out.println();
}
}

}

_____________________

Output:

*
**
***
****
*****
******
*******
********
*********
**********

**********
*********
********
*******
******
*****
****
***
**
*

**********
*********
********
*******
******
*****
****
***
**
*

*
**
***
****
*****
******
*******
********
*********
**********

_______________Thank You

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote