Write Java code that generates this exact print out using tw

Write Java code that generates this exact print out using two while loops: (15 pts.)

START!

1

1.1

2

2.1

2.2

3

3.1

3.2

3.3

4

4.1

4.2

4.3

4.4

5

5.1

5.2

5.3

5.4

5.5

END!

Please just use while loops only, thanks!

Solution

WhileLoops.java

import java.text.DecimalFormat;


public class WhileLoops {

   public static void main(String[] args) {
       int n = 5;
       int i= 1;
       System.out.println(\"START!\");
           while(i <= n){
               System.out.println(i);
               double sum = i;
               int j = 1;
               while(j <= i){
                   sum = sum + 0.1;
                   System.out.printf(\"%.1f\ \",sum);
                   j++;
               }
              
               i++;
           }
           System.out.println(\"END!\");
   }

}

Output:

START!
1
1.1
2
2.1
2.2
3
3.1
3.2
3.3
4
4.1
4.2
4.3
4.4
5
5.1
5.2
5.3
5.4
5.5
END!

Write Java code that generates this exact print out using two while loops: (15 pts.) START! 1 1.1 2 2.1 2.2 3 3.1 3.2 3.3 4 4.1 4.2 4.3 4.4 5 5.1 5.2 5.3 5.4 5.
Write Java code that generates this exact print out using two while loops: (15 pts.) START! 1 1.1 2 2.1 2.2 3 3.1 3.2 3.3 4 4.1 4.2 4.3 4.4 5 5.1 5.2 5.3 5.4 5.

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site