Using for loop, while loop, or do while loop to print a squarewhich has a 10x10
ID: 3617899 • Letter: U
Question
Using for loop, while loop, or do while loop to print a squarewhich has a 10x10 line of *except, line 8 consisting of # insteadof * (hint write a simple if statment within the loop) Final output should look like this: ********** ********** ********** ********** ********** ********** ********** ########## ********** ********** Using for loop, while loop, or do while loop to print a squarewhich has a 10x10 line of *except, line 8 consisting of # insteadof * (hint write a simple if statment within the loop) Final output should look like this: ********** ********** ********** ********** ********** ********** ********** ########## ********** **********Explanation / Answer
import java.util.*;
public class stars { public static void main(String args[]) { for(int v=1;v<11;v++) { if(v%8==0) { for(int a=1;a<=10;a++) System.out.print("#"); } else { for(int a=1;a<=10;a++) System.out.print("*"); } System.out.println(); } } }
import java.util.*;
public class stars { public static void main(String args[]) { for(int v=1;v<11;v++) { if(v%8==0) { for(int a=1;a<=10;a++) System.out.print("#"); } else { for(int a=1;a<=10;a++) System.out.print("*"); } System.out.println(); } } }
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.