Question: How to rewrite 'for' loops to do the same thing only using 'while' loops. It should produce same output as below. Java public class nestedFor7

How to rewrite 'for' loops to do the same thing only using 'while' loops. It should produce same output as below. Java

public class nestedFor7 { public static void main(String[] args) { int row = 4, counter = 2; for (int i = row; i > 0; i--){ for (int j = i+1; j > 1; j--){ if (i % 3 == 2){ System.out.print("7"); counter = counter + 1; } else System.out.print("1"); } System.out.println(); } System.out.println(counter); } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!