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

Please help me get whatever points still possible to get. It was due earlier. I

ID: 3884527 • Letter: P

Question


Please help me get whatever points still possible to get. It was due earlier. I didn't see the posting til 5 min ago.   Java eclipse neon related stuff. Show all steps please.

h. Printing 1 2 3 4 5 6 7 89 10 11 12 13 14 15 using either two (inner, outer) while loops or for loops. Hint: You may require about three variables for it. 2. Printing the above again, using a single while loop or a for loop. Hint: You will require three variables: One to assign the total count of the stars (15 in this case), one to assign the count of the stars on each line (5 in this case), and one 'counter' variable that starts with 1, goes until 5 and gets reset to 1 again after each line

Explanation / Answer

Question 1:

LoopTest.java

public class LoopTest {

public static void main(String[] args) {

int i,j,n = 15;

for(i=1;i<=n;i+=5) {

for(j=i;j<i+5;j++) {

System.out.print(j+" ");

}

System.out.println();

}

}

}

Output:

1 2 3 4 5
6 7 8 9 10
11 12 13 14 15

Question 2

Answer:

LoopTest.java

public class LoopTest {

public static void main(String[] args) {

int i=1,counter = 5,n = 15;

while(i<=n) {

System.out.print(i+" ");

if(i% counter ==0) {

System.out.println();

}

i++;

}

}

}

Output:

1 2 3 4 5
6 7 8 9 10
11 12 13 14 15