Question
Can i know what the explain comment with the step 1. import java.util.Scanner; public class StarLoop1 { public static void main(String[] args) { Scanner scanner
Can i know what the explain comment with the step
1.
import java.util.Scanner;
public class StarLoop1 {
public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.println("Please provide number of rows to print"); int myrows = scanner.nextInt(); for (int m = 1; m <= myrows; m++){ for (int n = 1; n <= m; n++){ System.out.print("*"); } System.out.println(); } } }
2.
import java.util.Scanner;
public class StarLoop2 { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.println("Please provide number of rows to print"); int myrows = scanner.nextInt(); for (int m = 0; m <= myrows; m++){ for (int n = myrows; n > m; n--){ System.out.print("*"); } System.out.println(); } } } 3.
import java.util.Scanner;
public class StarLoop3 { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.println("Please provide number of rows to print"); int myrows = scanner.nextInt(); for (int m = 1; m <= myrows; m++){ for (int n = 1; n < m; n++){ System.out.print(" "); } for (int p=myrows; p>=m; p--){ System.out.print("*"); } System.out.println(); } } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started