Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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